﻿'From Squeak6.1alpha of 27 January 2023 [latest update: #22417] on 3 February 2023 at 2:22:28 am'!

!LinkedList class methodsFor: 'as yet unclassified' stamp: 'jar 2/3/2023 02:13'!
releaseCriticalSection: aContext

	^aContext methodClass stepIntoCriticalSection: aContext! !


!Mutex class methodsFor: 'as yet unclassified' stamp: 'jar 2/3/2023 02:12'!
releaseCriticalSection: aContext

	^aContext pc: aContext endPC! !

!Mutex class methodsFor: 'as yet unclassified' stamp: 'jar 2/3/2023 02:12'!
stepIntoCriticalSection: aContext

	^(aContext stackPtr > 0 and: [aContext top == false]) 
		ifTrue: [aContext stepToCallee]
		ifFalse: [aContext]! !


!Process methodsFor: 'private' stamp: 'jar 2/3/2023 02:19'!
suspendAndReleaseCriticalSection
	"Figure out if we are terminating a process that is in the ensure: block of a critical section.
	 If it hasn't made progress but is beyond the wait (which we can tell by the oldList being
	 one of the runnable lists, i.e. a LinkedList, not a Semaphore or Mutex), then the ensure:
	 block needs to be run."

	"Suspend and unblock the receiver from a condition variable using suspend primitive #88.
	 It answers the list the receiver was on before the suspension."

	| oldList |
	oldList := self suspendAndUnblock ifNil: [LinkedList new].
	((suspendedContext ifNil: [^self]) method pragmaAt: #criticalSection) ifNil: [^self].
	suspendedContext := oldList class releaseCriticalSection: suspendedContext! !


!Semaphore class methodsFor: 'as yet unclassified' stamp: 'jar 2/3/2023 02:07'!
releaseCriticalSection: aContext

	^aContext pc: aContext endPC! !

!Semaphore class methodsFor: 'as yet unclassified' stamp: 'jar 2/3/2023 02:10'!
stepIntoCriticalSection: aContext

	^aContext stepToCallee! !

