sem_post(3R) manual page
Table of Contents
sem_post - increment the count of a semaphore
cc [ flag ...
] file ... -lposix4 [ library ... ]
#include <semaphore.h>
int sem_post(sem_t *sem);
typedef struct {
...
} sem_t /*opaque POSIX.4 semaphore*/
Async-Signal-Safe
If, prior to the call to sem_post(), the value of sem was
0, and other processes (or LWPs or threads) were blocked waiting for the
semaphore, then one of them will be allowed to return successfully from
its call to sem_wait(3R)
. The process to be unblocked will be chosen in
a manner appropriate to the scheduling policies and parameters in effect
for the blocked processes. In the case of the policies SCHED_FIFO and SCHED_RR,
the highest priority waiting process is unblocked, and if there is more
than one highest-priority process blocked waiting for the semaphore, then
the highest priority process which has been waiting the longest is unblocked.
If, prior to the call to sem_post(), no other processes ( or LWPs or thread)
were blocked for the semaphore, then its value is incremented by one.
sem_post()
is reentrant with respect to signals (ASYNC-SAFE), and may be invoked from
a signal-catching function. The semaphore functionality described on this
man page is for the POSIX threads implementation. For the documentation
of the Solaris threads interface, see semaphore(3T)
).
If successful,
sem_post() returns 0, otherwise it returns -1, and sets errno to indicate
the error condition.
- EINVAL
- sem does not refer to a valid semaphore.
- ENOSYS
- sem_post() is not supported by this implementation.
(see
sem_wait(3R)
)
sched_setscheduler(3R)
, sem_wait(3R)
, semaphore(3T)
sem_wait(3R)
and sem_trywait(3R)
decrement the semaphore upon their
successful return.
In Solaris 2.5, these functions always return -1 and
set errno
to ENOSYS,
because this release does not support the Semaphores
option. It is our intention to provide support for these interfaces in future
releases.
Table of Contents