Article View: comp.sys.sun
Article #12249Re: Lightweight processes?
From: Aaron Sloman
Date: Wed, 26 Apr 1989 00:04
Date: Wed, 26 Apr 1989 00:04
97 lines
3935 bytes
3935 bytes
odi!dlw@talcott.harvard.edu (Dan Weinreb, Object Design, Inc.) writes:
> I'm looking for a good lightweight process package, and would appreciate
> any help with the following questions:
>
> (1) Has anyone had experience with Sun's LWP library? Does it seem to
> work well? Did its performance seem good enough?
>
> (2) Is there any other lightweight process package available for Suns?
The Pop-11 subset of Poplog allows the creation of "lightweight"
processes that can be suspended then resumed (i.e. co-routines). The
process mechanism is accessible from the other Poplog languages: Prolog,
Common Lisp, and ML, by calling Pop-11 procedures.
> (3) Is there any lightweight process package that runs well on a wider
> range of Unix platforms than just Suns?
>
At present Poplog runs (with all its languages, the editor, libraries,
online documentation, etc.) on the following systems
VAX (VMS/Unix),
Sun2, Sun3, Sun4(SPARC), Sun386i (Road-runner),
HP 9000 300 series workstations with HPUX
Apollo with Bsd Unix
Sequent Symmetry with Dynix
Orion 1/05 (Unix with Clipper). This version is not supported at
present, but it appears to work.
-------
For example here's a little Pop-11 program that compares the "fringes"
(i.e. the leaves) on two binary trees, by alternately generating one
atom from each tree and stopping if they ever differ, or if they have
both been exhausted.
define fringe(tree);
;;; Recursive procedure to crawl round tree suspending process
;;; whenever a leaf of the tree is found.
if tree = [] then return
elseif atom(tree) then
suspend(tree,1)
else
fringe(front(tree));
fringe(back(tree))
endif;
enddefine;
define getfringe(tree);
;;; A procedure that runs fringe, then returns -termin- if
;;; fringe ever finishes.
fringe(tree);
return(termin)
enddefine;
define samefringe(tree1, tree2);
;;; Now the procedre that takes two trees, creates a leave-generating
;;; process for each, and compares them one at a time.
lvars tree1, tree2, proc1, proc2, next1, next2;
consproc(tree1, 1, getfringe) -> proc1;
consproc(tree2, 1, getfringe) -> proc2;
repeat
runproc(0, proc1) -> next1;
runproc(0, proc2) -> next2;
returnif(next1 /== next2)(false);
returnif(next1 == termin)(true);
endrepeat
enddefine;
;;;Now test the procedure on two trees with the same fringe but
;;;very differnt structures.
samefringe([1 [2 [3 [4]]]], [[1] 2 [[[3]]] 4 ]) =>
** <true>
It is also possible to implement a scheduler that interrupts and
suspends processes every so often, getting a new one from a process
queue each time. In fact we use this for teaching an elementary
course on operating systems.
For information about getting Poplog in USA and Canada contact
Prof Robin Popplestone at Univ. of Massachusetts: pop@cs.umass.edu
Aaron Sloman,
School of Cognitive and Computing Sciences,
Univ of Sussex, Brighton, BN1 9QN, England
ARPANET : aarons%uk.ac.sussex.cogs@nss.cs.ucl.ac.uk
aarons%uk.ac.sussex.cogs%nss.cs.ucl.ac.uk@relay.cs.net
JANET aarons@cogs.sussex.ac.uk
BITNET: aarons%uk.ac.sussex.cogs@uk.ac
or aarons%uk.ac.sussex.cogs%ukacrl.bitnet@cunyvm.cuny.edu
UUCP: ...mcvax!ukc!cogs!aarons
or aarons@cogs.uucp
Technical Details
Message-ID:
<26293.8904040148@csuna.cogs.susx.ac.uk>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-requestReferences:
<8903102058.AA00943@odi.odi.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-request From: aarons%cogs.sussex.ac.uk@nss.cs.ucl.ac.uk (Aaron Sloman) Newsgroups: comp.sys.sun Subject: Re: Lightweight processes? Keywords: Software Message-ID: <26293.8904040148@csuna.cogs.susx.ac.uk> Date: 26 Apr 89 00:04:00 GMT References: <8903102058.AA00943@odi.odi.com> Sender: usenet@rice.edu Organization: Sun-Spots Lines: 97 Approved: Sun-Spots@rice.edu Original-Date: Tue, 4 Apr 89 02:48:40 BST X-Sun-Spots-Digest: Volume 7, Issue 249, message 4 of 20