Next
Previous
Contents
All POSIX semaphore functions and types are prototyped or defined in
semaphore.h, and are completely unrelated to SYSV semaphores.
To create a new semaphore, you use sem_init().
- sem points to a semaphore object to initialize
- pshared is a flag indicating whether or not the semaphore should
be shared with fork()ed processes. LinuxThreads does not currently
support shared semaphores
- value is an initial value to set the semaphore to
- sem_wait blocks until the specified semaphore object's value is
greater than zero. it then decrements the semaphore's value by one
and returns
- like sem_wait, but returns immediately and does not decrement the
semaphore if it is zero
- increments the value of a semaphore
- gets the current value of sem and places it in the location pointed to
by valp
- destroys the semaphore; no threads should be waiting on the semaphore
if its destruction is to succeed.
Next
Previous
Contents