Category: Language-Processes
Superclass: LinkedList
My instances represent counting semaphores. I provide methods for signalling the semaphore's availability, and methods for waiting for its availability. I also provide some methods for implementing critical sections.

Method category index

instance creation (class)
accessing (instance)
builtins (instance)
mutual exclusion (instance)
printing (instance)

instance creation (class)

forMutualExclusion
Answer a new semaphore with a signal on it. These semaphores are a useful shortcut when you use semaphores as critical sections.

top


accessing (instance)

name
Answer a user-friendly name for the receiver

name: aString

Answer a user-friendly name for the receiver

waitingProcesses

Answer an Array of processes currently waiting on the receiver.

wouldBlock

Answer whether waiting on the receiver would suspend the current process.

top


builtins (instance)

lock
Without putting the receiver to sleep, force processes that try to wait on the semaphore to block. Answer whether this was the case even before.

notify

Resume one of the processes that were waiting on the semaphore if there were any. Do not leave a signal on the semaphore if no process is waiting.

notifyAll

Resume all the processes that were waiting on the semaphore if there were any. Do not leave a signal on the semaphore if no process is waiting.

signal

Signal the receiver, resuming a waiting process' if there is one

wait

Wait for the receiver to be signalled, suspending the executing process if it is not yet. Return nil if the wait was interrupted, the receiver otherwise.

waitAfterSignalling: aSemaphore

Signal aSemaphore then, atomically, wait for the receiver to be signalled, suspending the executing process if it is not yet. This is needed to avoid race conditions when the #notify and #notifyAll are used before waiting on receiver: otherwise, if a process sends any of the two between the time aSemaphore is signaled and the time the process starts waiting on the receiver, the notification is lost.

top


mutual exclusion (instance)

critical: aBlock
Wait for the receiver to be free, execute aBlock and signal the receiver again. Return the result of evaluating aBlock.

top


printing (instance)

printOn: aStream
Print a human-readable represention of the receiver on aStream.

top