sem_post(3pthread)
sem_post --
unlock a semaphore
Synopsis
cc [options] -Kthread file
#include <semaphore.h>
int sem_post(sem_t *sem);
Description
sem_post increments the count
of the semaphore pointed to by sem,
and, if the new count value is less than or equal to zero,
makes the next thread waiting at the semaphore runnable.
If the semaphore value resulting from this operation is positive,
then no threads were blocked waiting for the semaphore to become
unlocked;
the semaphore value is simply incremented.
sem is a pointer to the semaphore to
increment and must previously have been initialized
by sem_init.
The highest priority waiting thread
will be unblocked, and if there is more than one
highest priority thread blocked waiting for the
semaphore, then the highest priority thread that has been
waiting the longest will be unblocked.
sem_post is reentrant with respect to signals
and may be invoked from a signal-catching function.
Return values
sem_post returns zero on success.
Otherwise, it returns -1 and sets errno
to indicate the error.
Diagnostics
sem_post returns -1 and sets errno to
the following values
if the corresponding conditions are detected:
EINVAL-
invalid argument specified
Standards compliance
The Single UNIX Specification, Version 2; The Open Group.
References
Intro(3pthread),
sem_destroy(3pthread),
sem_init(3pthread),
sem_trywait(3pthread),
sem_wait(3pthread)
semaphore(4)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004