QSemN
is a quantity semaphore in which the resource is aqcuired
and released in units of one. It provides guaranteed FIFO ordering
for satisfying blocked waitQSemN
calls.
The pattern
bracket_ (waitQSemN n) (signalQSemN n) (...)
is safe; it never loses any of the resource.