|
Semaphores and the schedulerA coroutining primitive allows a preemptive scheduler to be constructed entirely in Self. The scheduling process has special status as a distinguished process.The scheduler is in a global slot, scheduler. Typing ^C into the controlling terminal window suspends all processing and causes the scheduler to list runnable and sleeping processes; these can be killed, suspended or resumed. Semaphores are implemented in Self with the cooperation of the scheduler. Classical semaphores are obtained by sending copy, copyBinary to semaphore. Semaphores understand signal and wait, and can be used to implement critical regions using protect: aBlock (which waits before executing the block, then signals). A recursiveSemaphore is like a semaphore excepts multiple waits from within the same process count as a single wait. This can be useful in avoiding deadlock.
|