[squeak-dev] The Trunk: Kernel-jar.1476.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Jun 9 08:15:48 UTC 2022

Marcel Taeumel uploaded a new version of Kernel to project The Trunk:

==================== Summary ====================

Name: Kernel-jar.1476
Author: jar
Time: 7 June 2022, 5:26:20.195964 pm
UUID: 485a13c3-c632-aa4b-bc0d-a1a7fb9a3376
Ancestors: Kernel-jar.1475

- fix synchronization between the terminating process and the process that invoked the termination
- add further protection against multiple termination (it makes the code uglier but I can't help it)
- improve the comment (it's still too long and insufficient though ;) )

Complemented by additional tests (I'll bundle all of them in one changeset)

=============== Diff against Kernel-jar.1475 ===============

Item was changed:
  ----- Method: Process>>terminate (in category 'changing process state') -----
  	"Stop the process that the receiver represents forever.
  	 Unwind to execute pending #ensure:/#ifCurtailed: blocks before terminating;
  	 allow all unwind blocks to run; if they are currently in progress, let them finish."
  	 "This is the kind of behavior we expect when terminating a healthy process.
  	 See further comments in #terminateAggressively and #destroy methods dealing 
  	 with process termination when closing the debugger or after a catastrophic failure.
  	 If terminating the active process, create a new stack and run unwinds from there.
  	 If terminating a suspended process (including runnable and blocked), always
  	 suspend the terminating process first so it doesn't accidentally get woken up. 
  	 Equally important is the side effect of the suspension: In 2022 a new suspend
  	 semantics has been introduced: the revised #suspend backs up a process waiting
  	 on a conditional variable to the send that invoked the wait state, while the previous
  	 #suspend simply removed the process from the conditional variable's list it was
  	 previously waiting on; see #suspend and #suspendAndUnblock comments.
  	 If the process is in the middle of a #critical: critical section, release it properly.
  	 To allow a suspended process to unwind itself, create a new stack for the process
  	 being terminated and resume the suspended process to complete its termination
  	 from the new parallel stack. Use a semaphore to make the process that invoked
  	 the termination wait for self's completion. Execute the termination in the ensure
  	 argument block to ensure it completes even if the terminator process itself gets
+ 	 terminated before it's finished; see testTerminateInTerminate and others."
- 	 terminated before it's finished; see testTerminateInTerminate."
  	| context |
  	self isActiveProcess ifTrue: [
  		context := thisContext.
+ 		^[[] ensure: [context unwindTo: nil]. self suspend] asContext jump].
- 		^[context unwindTo: nil. self suspend] asContext jump].
  	[] ensure: [ | terminator |
  		self suspendAndReleaseCriticalSection.
  		context := suspendedContext ifNil: [^self].
  		terminator := Semaphore new.
+ 		context bottomContext insertSender: (Context contextEnsure: [terminator signal]).
+ 		self suspendedContext: [[] ensure: [context unwindTo: nil]. self suspend] asContext;
+ 			priority: Processor activePriority;
+ 			resume.
- 		suspendedContext := [context unwindTo: nil. terminator signal. self suspend] asContext.
- 		self priority: Processor activePriority; resume.
  		terminator wait]!

More information about the Squeak-dev mailing list