A semaphore has an internal counter; when this counter is zero, the semaphore can block a thread’s execution (through semaphore-wait) until another thread increments the counter (using semaphore-post). The maximum value for a semaphore’s internal counter is platform-specific, but always at least 10000.
A semaphore’s counter is updated in a single-threaded manner, so that semaphores can be used for reliable synchronization. Semaphore waiting is fair: if a thread is blocked on a semaphore and the semaphore’s internal value is non-zero infinitely often, then the thread is eventually unblocked.
In addition to its use with semaphore-specific procedures, a semaphore can be used as a synchronizable event (see Events). A semaphore is ready for synchronization when semaphore-wait would not block. Upon synchronization, the semaphore’s counter is decremented, and the synchronization result of a semaphore is the semaphore itself.
Returns
#tif
vis a
semaphore,
#fotherwise.
Creates and returns a new semaphore with the counter initially set to
init. If
initis larger than a semaphore’s maximum internal counter value, the
exn:failexception is raised.
Increments the semaphore’s internal counter and returns
#<void>. If the semaphore’s internal counter has already reached its maximum value, the
exn:failexception is raised.
Blocks until the internal counter for semaphore
semais non-zero. When the counter is non-zero, it is decremented and
semaphore-waitreturns
#<void>.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4