[Pkg] The Trunk: Kernel-eem.974.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Jan 7 22:09:19 UTC 2016


Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.974.mcz

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

Name: Kernel-eem.974
Author: eem
Time: 7 January 2016, 11:31:01.579217 am
UUID: 3c4d15d0-4d46-4013-af15-4c930e58f6e2
Ancestors: Kernel-eem.973

Reshape Monitor and Mutex and add the critical section primitives in advance of changing over to the critical section primitives.

=============== Diff against Kernel-eem.973 ===============

Item was changed:
+ LinkedList subclass: #Monitor
+ 	instanceVariableNames: 'ownerProcess defaultQueue queueDict queuesMutex mutex nestingLevel'
- Object subclass: #Monitor
- 	instanceVariableNames: 'mutex ownerProcess nestingLevel defaultQueue queueDict queuesMutex'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'Kernel-Processes'!
  
  !Monitor commentStamp: 'md 3/3/2006 09:19' prior: 0!
  A monitor provides process synchronization that is more high level than the one provided by a Semaphore. Similar to the classical definition of a Monitor it has the following properties:
  
  1) At any time, only one process can execute code inside a critical section of a monitor.
  2) A monitor is reentrant, which means that the active process in a monitor never gets blocked when it enters a (nested) critical section of the same monitor.
  3) Inside a critical section, a process can wait for an event that may be coupled to a certain condition. If the condition is not fulfilled, the process leaves the monitor temporarily (in order to let other processes enter) and waits until another process signals the event. Then, the original process checks the condition again (this is often necessary because the state of the monitor could have changed in the meantime) and continues if it is fulfilled.
  4) The monitor is fair, which means that the process that is waiting on a signaled condition the longest gets activated first.
  5) The monitor allows you to define timeouts after which a process gets activated automatically.
  
  
  Basic usage:
  
  Monitor>>critical: aBlock
  Critical section.
  Executes aBlock as a critical section. At any time, only one process can execute code in a critical section.
  NOTE: All the following synchronization operations are only valid inside the critical section of the monitor!!
  
  Monitor>>wait
  Unconditional waiting for the default event.
  The current process gets blocked and leaves the monitor, which means that the monitor allows another process to execute critical code. When the default event is signaled, the original process is resumed.
  
  Monitor>>waitWhile: aBlock
  Conditional waiting for the default event.
  The current process gets blocked and leaves the monitor only if the argument block evaluates to true. This means that another process can enter the monitor. When the default event is signaled, the original process is resumed, which means that the condition (argument block) is checked again. Only if it evaluates to false, does execution proceed. Otherwise, the process gets blocked and leaves the monitor again...
  
  Monitor>>waitUntil: aBlock
  Conditional waiting for the default event.
  See Monitor>>waitWhile: aBlock.
  
  Monitor>>signal
  One process waiting for the default event is woken up.
  
  Monitor>>signalAll
  All processes waiting for the default event are woken up.
  
  
  Using non-default (specific) events:
  
  Monitor>>waitFor: aSymbol
  Unconditional waiting for the non-default event represented by the argument symbol.
  Same as Monitor>>wait, but the process gets only reactivated by the specific event and not the default event.
  
  Monitor>>waitWhile: aBlock for: aSymbol
  Confitional waiting for the non-default event represented by the argument symbol.
  Same as Monitor>>waitWhile:for:, but the process gets only reactivated by the specific event and not the default event.
  
  Monitor>>waitUntil: aBlock for: aSymbol
  Confitional waiting for the non-default event represented by the argument symbol.
  See Monitor>>waitWhile:for: aBlock.
  
  Monitor>>signal: aSymbol
  One process waiting for the given event is woken up. If there is no process waiting for this specific event, a process waiting for the default event gets resumed.
  
  Monitor>>signalAll: aSymbol
  All process waiting for the given event or the default event are woken up.
  
  Monitor>>signalReallyAll
  All processes waiting for any events (default or specific) are woken up.
  
  
  Using timeouts
  
  Monitor>>waitMaxMilliseconds: anInteger
  Monitor>>waitFor: aSymbol maxMilliseconds: anInteger
  Same as Monitor>>wait (resp. Monitor>>waitFor:), but the process gets automatically woken up when the specified time has passed.
  
  Monitor>>waitWhile: aBlock maxMilliseconds: anInteger
  Monitor>>waitWhile: aBlock for: aSymbol maxMilliseconds: anInteger
  Same as Monitor>>waitWhile: (resp. Monitor>>waitWhile:for:), but the process gets automatically woken up when the specified time has passed.
  
  Monitor>>waitUntil: aBlock maxMilliseconds: anInteger
  Monitor>>waitUntil: aBlock for: aSymbol maxMilliseconds: anInteger
  Same as Monitor>>waitUntil: (resp. Monitor>>waitUntil:for:), but the process gets automatically woken up when the specified time has passed.!

Item was added:
+ ----- Method: Monitor>>primitiveEnterCriticalSection (in category 'private-primitives') -----
+ primitiveEnterCriticalSection
+ 	"Primitive. The receiver must be unowned or owned by the current process to proceed.
+ 	 Answer if the process is owned by the current process.
+ 
+ 	 Copyright (c) 2016 - 3D Immersive Collaboration Consulting, LLC."
+ 	<primitive: 186>
+ 	self primitiveFailed
+ 	"In the spirit of the following"
+ 	"[owner ifNil:
+ 		[owner := Processor activeProcess.
+ 		 ^false].
+ 	  owner = Processor activeProcess ifTrue:
+ 		[^true].
+ 	  self addLast: Processor activeProcess.
+ 	  Processor activeProcess suspend] valueUnpreemptively"!

Item was added:
+ ----- Method: Monitor>>primitiveExitCriticalSection (in category 'private-primitives') -----
+ primitiveExitCriticalSection
+ 	"Primitive. Set the receiver to unowned and if any processes are waiting on
+ 	 the receiver then proceed the first one, indicating that the receiver is unowned.
+ 
+ 	 Copyright (c) 2016 - 3D Immersive Collaboration Consulting, LLC."
+ 	<primitive: 185>
+ 	self primitiveFailed
+ 	"In the spirit of the following"
+ 	"[owner := nil.
+ 	  self isEmpty ifFalse:
+ 		[process := self removeFirst.
+ 		 process resume]] valueUnpreemptively"!

Item was added:
+ ----- Method: Monitor>>primitiveTestAndSetOwnershipOfCriticalSection (in category 'private-primitives') -----
+ primitiveTestAndSetOwnershipOfCriticalSection
+ 	"Primitive. Attempt to set the ownership of the receiver.
+ 	 If the receiver is unowned set its owningProcess to the
+ 	 activeProcess and answer false.  If the receiver is owned
+ 	 by the activeProcess answer true.  If the receiver is owned
+ 	 by some other process answer nil.
+ 
+ 	 Copyright (c) 2016 - 3D Immersive Collaboration Consulting, LLC."
+ 	<primitive: 187>
+ 	self primitiveFail
+ 	"In the spirit of the following"
+ 	"[owner ifNil:
+ 		[owningProcess := Processor activeProcess.
+ 		 ^false].
+ 	  owner = Processor activeProcess ifTrue: [^true].
+ 	  ^nil] valueUnpreemptively"!

Item was changed:
+ LinkedList subclass: #Mutex
+ 	instanceVariableNames: 'owner semaphore'
- Object subclass: #Mutex
- 	instanceVariableNames: 'semaphore owner'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'Kernel-Processes'!
  
  !Mutex commentStamp: '<historical>' prior: 0!
  A Mutex is a light-weight MUTual EXclusion object being used when two or more processes need to access a shared resource concurrently. A Mutex grants ownership to a single process and will suspend any other process trying to aquire the mutex while in use. Waiting processes are granted access to the mutex in the order the access was requested.
  
  Instance variables:
  	semaphore	<Semaphore>		The (primitive) semaphore used for synchronization.
  	owner		<Process>		The process owning the mutex.!

Item was added:
+ ----- Method: Mutex>>primitiveEnterCriticalSection (in category 'private-primitives') -----
+ primitiveEnterCriticalSection
+ 	"Primitive. The receiver must be unowned or owned by the current process to proceed.
+ 	 Answer if the process is owned by the current process.
+ 
+ 	 Copyright (c) 2016 - 3D Immersive Collaboration Consulting, LLC."
+ 	<primitive: 186>
+ 	self primitiveFailed
+ 	"In the spirit of the following"
+ 	"[owner ifNil:
+ 		[owner := Processor activeProcess.
+ 		 ^false].
+ 	  owner = Processor activeProcess ifTrue:
+ 		[^true].
+ 	  self addLast: Processor activeProcess.
+ 	  Processor activeProcess suspend] valueUnpreemptively"!

Item was added:
+ ----- Method: Mutex>>primitiveExitCriticalSection (in category 'private-primitives') -----
+ primitiveExitCriticalSection
+ 	"Primitive. Set the receiver to unowned and if any processes are waiting on
+ 	 the receiver then proceed the first one, indicating that the receiver is unowned.
+ 
+ 	 Copyright (c) 2016 - 3D Immersive Collaboration Consulting, LLC."
+ 	<primitive: 185>
+ 	self primitiveFailed
+ 	"In the spirit of the following"
+ 	"[owner := nil.
+ 	  self isEmpty ifFalse:
+ 		[process := self removeFirst.
+ 		 process resume]] valueUnpreemptively"!

Item was added:
+ ----- Method: Mutex>>primitiveTestAndSetOwnershipOfCriticalSection (in category 'private-primitives') -----
+ primitiveTestAndSetOwnershipOfCriticalSection
+ 	"Primitive. Attempt to set the ownership of the receiver.
+ 	 If the receiver is unowned set its owningProcess to the
+ 	 activeProcess and answer false.  If the receiver is owned
+ 	 by the activeProcess answer true.  If the receiver is owned
+ 	 by some other process answer nil.
+ 
+ 	 Copyright (c) 2016 - 3D Immersive Collaboration Consulting, LLC."
+ 	<primitive: 187>
+ 	self primitiveFail
+ 	"In the spirit of the following"
+ 	"[owner ifNil:
+ 		[owningProcess := Processor activeProcess.
+ 		 ^false].
+ 	  owner = Processor activeProcess ifTrue: [^true].
+ 	  ^nil] valueUnpreemptively"!



More information about the Packages mailing list