[squeak-dev] The Inbox: Kernel-jar.1377.mcz

Jaromir Matas m at jaromir.net
Wed Mar 3 22:10:45 UTC 2021


Fix inconsistent bahavior in #isTerminated and #isSuspended 


Following up on a discussion with Eliot (
http://forum.world.st/The-Inbox-Kernel-jar-1376-mcz-td5127335.html
<http://forum.world.st/The-Inbox-Kernel-jar-1376-mcz-td5127335.html>  ) I'm
proposing changes to #isTerminated, #isSuspended and Eliot's hack to
#terminate to remove inconsistency in reporting the termination status in
some rare cases. 


A suggestion: When a process is terminated and later resumed it raises a
cannotReturn: error. Is raising an error/debugger desirable? Looping the
resumed process back to terminate would do no harm and raise no error...

terminate 
	"Stop the process that the receiver represents forever.
	 Unwind to execute pending ensure:/ifCurtailed: blocks before terminating.
	 If the process is in the middle of a critical: critical section, release
it properly."

	| terminationStatus ctxt unwindBlock oldList |
	self isActiveProcess ifTrue:
		[ctxt := thisContext.
		 [ctxt := ctxt findNextUnwindContextUpTo: nil.
		  ctxt ~~ nil] whileTrue:
			[(ctxt tempAt: 2) ifNil:
				["N.B. Unlike Context>>unwindTo: we do not set complete (tempAt: 2) to
true."
				 unwindBlock := ctxt tempAt: 1.
				 thisContext terminateTo: ctxt.
				 unwindBlock value]].
		thisContext terminateTo: nil.
		terminationStatus := #terminated.
		self suspend.
>>>	        thisContext restart].  "add this and remove ^self below"

		"If the process is resumed this will provoke a cannotReturn: error.
		 Would self debug: thisContext title: 'Resuming a terminated process' be
better?"
		^self].

		"..."


And finally: Is there a reason why processes created directly via Process
forContext:priority: are not subject to tests? Like e.g.:

	"These processes should be terminated, not suspended."
	self deny: (Process forContext: [Processor activeProcess suspend] priority:
Processor activePriority + 1) resume isSuspended.
	self assert: (Process forContext: [Processor activeProcess suspend]
priority: Processor activePriority + 1) resume isTerminated.

If not, I could add some...

regards,



-----
^[^ Jaromir
--
Sent from: http://forum.world.st/Squeak-Dev-f45488.html


More information about the Squeak-dev mailing list