sem_post(S)
sem_post --
unlock a semaphore
Syntax
cc . . . -lsuds
#include <semaphore.h>
int sem_post(semt *sem);
Description
The sem_post function unlocks the semaphore referenced by
sem by performing the semaphore unlock operation on that
semaphore. If the semaphore value resulting from this operation is
positive, then no processes were blocked waiting for the semaphore
to become unlocked; the semaphore value is simply incremented.
If the value of the semaphore resulting from this operation is zero,
then one of the processes blocked waiting for the semaphore is
allowed to return successfully from its call to
sem_wait(S).
The process to be unblocked shall be chosen in a manner appropriate
to the scheduling policies and parameters in effect for the blocked
processes. In the case of the schedulers 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.
The sem_post function is re-entrant with respect to
signals and may be invoked from a signal-catching function.
Return values
If successful, the sem_post function returns zero;
otherwise the function returns -1, and sets errno to
indicate the error.
Diagnostics
If the following condition occurs, the sem_post function
returns -1 and sets errno to the corresponding value:
[EINVAL]-
The sem does not refer to a valid semaphore.
See also
semaphore(FP),
sem_trywait(S),
sem_wait(S)
Standards conformance
Text reprinted and/or adapted from IEEE Std 1003.1b-1993,
IEEE Standard for Information Technology, POSIX
Part 1: System Application Program Interface (API)
Amendment 1: Realtime Extensions [C Language], copyright © 1993
by the Institute of Electrical and Electronics Engineers, Inc. The
IEEE takes no responsibility for and will assume no
liability for damages resulting from the reader's misinterpretation
of said information resulting from the placement and context in this
publication. Information is reproduced with the permission of the
IEEE.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003