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(3synch)
function can validly be used to
increase a semaphore count above that defined by
sema_init(3synch).
Next topic:
Barriers
Previous topic:
Reader-writer locks
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004