Semaphores
Semaphores are a facility well-suited to managing the
allocation and deallocation of identical resources.
Additional considerations:
-
This mechanism lacks the following features of the IPC style semaphore facility:
-
Increment/decrement by values greater than 1.
-
Operations on semaphore sets.
-
The ability to, ``block while count is non-zero''
instead of the usual rule, ``block only when count is zero.''
-
The ability to automatically release semaphores on termination
(SEM_UNDO flag).
-
A semaphore initialized to 1 is almost equivalent to a mutex.
In such cases, use the mutex facilities;
they are more efficient, having been optimized for that case.
-
The
sema_post(S)
function can validly be used to
increase a semaphore count above that defined by
sema_init(S).
Next topic:
Barriers
Previous topic:
Reader-writer locks
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005