Lightweight processes?

Aaron Sloman aarons%cogs.sussex.ac.uk at nss.cs.ucl.ac.uk
Wed Apr 26 10:04:00 AEST 1989


odi!dlw at 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 at cs.umass.edu

Aaron Sloman,
School of Cognitive and Computing Sciences,
Univ of Sussex, Brighton, BN1 9QN, England
    ARPANET : aarons%uk.ac.sussex.cogs at nss.cs.ucl.ac.uk
              aarons%uk.ac.sussex.cogs%nss.cs.ucl.ac.uk at relay.cs.net
    JANET     aarons at cogs.sussex.ac.uk
    BITNET:   aarons%uk.ac.sussex.cogs at uk.ac
        or    aarons%uk.ac.sussex.cogs%ukacrl.bitnet at cunyvm.cuny.edu

    UUCP:     ...mcvax!ukc!cogs!aarons
            or aarons at cogs.uucp



More information about the Comp.sys.sun mailing list