[squeak-dev] The Trunk: Kernel-ar.238.mcz

Michael van der Gulik mikevdg at gmail.com
Sat Sep 5 00:55:10 UTC 2009


On Fri, 4 Sep 2009 04:51:35 0000, commits at source.squeak.org
<commits at source.squeak.org> wrote:
> Andreas Raab uploaded a new version of Kernel to project The Trunk:
> http://source.squeak.org/trunk/Kernel-ar.238.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-ar.238
> Author: ar
> Time: 3 September 2009, 9:50:51 am
> UUID: 9896c3f8-760f-e942-ac84-5f6c9127150c
> Ancestors: Kernel-ar.237
>
> http://bugs.squeak.org/view.php?id=7321
>
> Change Set:		AtomicProcessSuspend
> Date:			23 March 2009
> Author:			Andreas Raab
>
> In-image support for atomic process suspend.
>
> =============== Diff against Kernel-ar.237 ===============
>
> Item was changed:
>   ----- Method: Process>>suspend (in category 'changing process state')
> -----
>   suspend
> + 	"Primitive. Stop the process that the receiver represents in such a way
> - 	"Stop the process that the receiver represents in such a way
>   	that it can be restarted at a later time (by sending the receiver the
>   	message resume). If the receiver represents the activeProcess, suspend
> it.
> + 	Otherwise remove the receiver from the list of waiting processes.
> + 	The return value of this method is the list the receiver was previously
> on (if any)."
> + 	| oldList |
> + 	<primitive: 88>
> + 	"This is fallback code for VMs which only support the old
> primitiveSuspend which
> + 	would not accept processes that are waiting to be run."
> + 	myList ifNil:[^nil]. "this allows us to use suspend multiple times"
> + 	oldList := myList.
> + 	myList := nil.
> + 	oldList remove: self ifAbsent:[].
> + 	^oldList!
> - 	Otherwise remove the receiver from the list of waiting processes."
> -
> - 	self isActiveProcess ifTrue: [
> - 		myList := nil.
> - 		self primitiveSuspend.
> - 	] ifFalse: [
> - 		myList ifNotNil: [
> - 			myList remove: self ifAbsent: [].
> - 			myList := nil].
> - 	]
> - !
>
> Item was changed:
>   ----- Method: Process>>offList (in category 'accessing') -----
>   offList
> + 	"OBSOLETE. Process>>suspend will atomically reset myList if the process
> is suspended.
> + 	There should never be a need to send #offList but some older users may
> not be aware
> + 	of the changed semantics to suspend and may try the old hickadidoo seen
> here:
> - 	"Inform the receiver that it has been taken off a list that it was
> - 	suspended on. This is to break a backpointer."
>
> + 		(suspendingList := process suspendingList) == nil
> + 			ifTrue: [process == Processor activeProcess ifTrue: [process suspend]]
> + 			ifFalse: [suspendingList remove: process ifAbsent:[].
> + 					process offList].
> +
> + 	Usages like the above should be replaced by a simple 'process suspend' "
>   	myList := nil!
>
> Item was changed:
>   ----- Method: Process>>terminate (in category 'changing process state')
> -----
>   terminate
>   	"Stop the process that the receiver represents forever.  Unwind to
> execute pending ensure:/ifCurtailed: blocks before terminating."
>
> + 	| ctxt unwindBlock oldList |
> - 	| ctxt unwindBlock inSema |
>   	self isActiveProcess ifTrue: [
>   		ctxt := thisContext.
>   		[	ctxt := ctxt findNextUnwindContextUpTo: nil.
>   			ctxt isNil
>   		] whileFalse: [
>   			unwindBlock := ctxt tempAt: 1.
>   			unwindBlock ifNotNil: [
>   				ctxt tempAt: 1 put: nil.
>   				thisContext terminateTo: ctxt.
>   				unwindBlock value].
>   		].
>   		thisContext terminateTo: nil.
> + 		self suspend.
> + 	] ifFalse:[
> + 		myList ifNotNil:[oldList := self suspend].
> + 		suspendedContext ifNotNil:[
> - 		myList := nil.
> - 		self primitiveSuspend.
> - 	] ifFalse: [
> - 		"Since the receiver is not the active process, drop its priority to
> rock-bottom so that
> - 		it doesn't accidentally preempt the process that is trying to terminate
> it."
> - 		priority := 10.

I admit not fully understanding everything here, but should you
perhaps have kept the priority drop here? Otherwise, by my
understanding, the process that is meant to be terminated might be
restarted in this line here before it gets suspended:

> + 		myList ifNotNil:[oldList := self suspend].



Gulik.

-- 
http://gulik.pbwiki.com/



More information about the Squeak-dev mailing list