Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!portc01.blue.aol.com!news-peer.gsl.net!news.gsl.net!news.mathworks.com!fu-berlin.de!unlisys!blackbush.xlink.net!ins.net!heeg.de!hmm
From: hmm@heeg.de (Hans-Martin Mosner)
Subject: Re: [VW2.51] Checking termination of Process?
Message-ID: <E0pAB4.MGF@heeg.de>
Sender: uucp@heeg.de
Organization: Georg Heeg Objektorientierte Systeme, Dortmund, FRG
X-Newsreader: TIN [version 1.2 PL2]
References: <558m60$eke@news00.btx.dtag.de> <55n6l5$h0f@mailsrv2.erno.de> <55usj8$7in@news00.btx.dtag.de>
Date: Mon, 11 Nov 1996 09:57:04 GMT
Lines: 67

Thilo Schmid (Thilo.KHK@t-online.de) wrote:

: [...] let me ask one more
: "philosophical" question: how would you call a Process which does have a
: suspendedContext ~~ nil and is not in the queue of scheduled processes
: maintained by the Processor instance ? Although there is no protocol to
: remove it from the Processor in this way, this process has no chance to
: proceed, because it's suspendedContext will never become an active
: context. So is this Process "terminated" or not?

It's a suspended process, as simple as that. As long as it still exists
(because you have it in a variable, or because the GC did not get it yet)
you can send it a #resume message, and it will happily resume its work.
It may be waiting on a Semaphore, for example.

: Take into account, that Processor is the global instance which usually
: prevents the garbage collector from collecting suspended processes
No! Processor keeps the active process and runnable processes alive.
Suspended processes are kept alive either by Semaphores on which they
are waiting, or by some variable that holds a reference to them.

: (there is no explicit definition of how and why the garbage collector is
: prevented to collect the contents of thisContext).
A process is an object like any other object. As long as you have a
reference to it, it will not be garbage collected. Whether it's the
Processor or some other object in your system that holds the reference
is only a technical detail.

: Removing a Process
: from the Processor will cause the Process to vanish into the garbage
: collector without any change of it's state (as long as it is not held by
: someone else). Would you agree that this process is terminated?

Yes, it is. But you can't ask it anymore. If you could still ask it, it
would not be terminated :-)

So there are really a number of states a process can be in, and a number
of possible transitions between these states:

		active	runnable    suspended	terminated   non-existing
active		-	*	    #suspend	#terminate   **
runnable	*	-	    #suspend	#terminate   **
suspended	#resume	#resume	    -		#terminate   ***
terminated	****	****	    *****	-	     ***
non-existing	(a non-existing object does not change state anymore)

Notes:
	There are many variations of #suspend and #resume, mostly related
	to Sempahores. They would not all fit into the table...
*	Changes between active and runnable does not happen by messages sent to
	the process, but by higher-priority processes becoming active/inactive.
**	Active and runnable processes are held by the Processor, therefore
	they cannot become non-existing.
***	When the last reference to a suspended or terminated process is lost,
	it is eligible for garbage collection. However, with current memory
	managements, it may be possible to revive such a process.
****	Terminated processes can not become active or runnable.
*****	As a previous poster noted, you can revive terminated processes with
	#installOn:.

Hans-Martin

--
+--- Hans-Martin Mosner ---- Senior Smalltalk Guru :-) ---+
| These opinions are entirely ficticious.  Any similarity |
| to real opinions is purely coincidental and unintended. |
+--- <hmm@heeg.de> ------ URL:http://www.heeg.de/~hmm/ ---+
