[squeak-dev] New #terminate - Back to the Past...

mail at jaromir.net mail at jaromir.net
Tue Feb 22 19:18:51 UTC 2022

Hi all,

I'm enclosing my latest version of the new #terminate and have sent it to the Inbox: Kernel-jar.1447

After many iterations I've arrived at a code with a very similar structure as the original elegant code in Squeak versions 1 through 3.5 :) I admired the simplicity of the original code authored by tfei and tpr (hi Tim!) using Context>>#unwindTo: to deal with all unwinds. The enclosed version of unwindTo: fixes some issues with non-local returns and extends the unwind semantics a bit (see comments in the methods).

The posted version of #terminate works independently of the revised suspend semantics currently being implemented in the VM by Eliot (i.e. works in all scenarios). 

The original thread documenting my attempts to rewrite #terminate started here: http://forum.world.st/Solving-multiple-termination-bugs-summary-amp-proposal-td5128285.html

Please review the enclosed proposal. The main highlights of the solution are:
1. direct termination - the unwind blocks are always executed by the process being terminated (i.e. termination is process faithful)
2. code structure follows (or copies) the structure used in the early Squeak implementation (versions 1 up to 3.5)
3. non-local returns can be placed anywhere inside unwind blocks, even nested etc.

Compare the proposed and the original #teminate from 1999 :)


	"Stop the process that the receiver represents forever."

	| context |
	self isActiveProcess ifTrue: [
		context := thisContext.
		^[context unwindTo: nil. self suspend] asContext jump].

	[] ensure: [ | oldList |
		oldList := myList.
		self suspend.
		context := suspendedContext ifNil: [^self].
		suspendedContext := [
			context releaseCriticalSection: oldList; unwindTo: nil. 
			self suspend] asContext.
		self priority: Processor activePriority + 1; resume]


	"Stop the process that the receiver represents forever."

	| context |
	Processor activeProcess == self
			[thisContext unwindTo: nil.
			thisContext sender == nil ifFalse:
				[thisContext sender release].
			thisContext removeSelf suspend]
			[myList == nil
					[myList remove: self ifAbsent: [].
					myList _ nil].
			context _ suspendedContext.
			suspendedContext _ nil.
			context == nil ifFalse: [context unwindTo: nil].
			(context ~~ nil and: [context sender ~~ nil])
				ifTrue: [context sender release]]

Sent from Squeak Inbox Talk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Terminate.1.cs
Type: application/octet-stream
Size: 8861 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220222/5a7a3e72/attachment.obj>

More information about the Squeak-dev mailing list