1SEM_POST(3P)               POSIX Programmer's Manual              SEM_POST(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       sem_post - unlock a semaphore (REALTIME)
13

SYNOPSIS

15       #include <semaphore.h>
16
17       int sem_post(sem_t *sem);
18
19

DESCRIPTION

21       The sem_post() function shall unlock the semaphore referenced by sem by
22       performing a semaphore unlock operation on that semaphore.
23
24       If  the semaphore value resulting from this operation is positive, then
25       no threads were blocked waiting for the semaphore to  become  unlocked;
26       the semaphore value is simply incremented.
27
28       If  the  value  of the semaphore resulting from this operation is zero,
29       then one of the threads blocked waiting  for  the  semaphore  shall  be
30       allowed  to  return  successfully from its call to sem_wait().   If the
31       Process Scheduling option is supported,  the  thread  to  be  unblocked
32       shall  be chosen in a manner appropriate to the scheduling policies and
33       parameters in effect for the blocked threads. In the case of the sched‐
34       ulers  SCHED_FIFO  and  SCHED_RR,  the  highest priority waiting thread
35       shall be unblocked, and if there is  more  than  one  highest  priority
36       thread  blocked  waiting  for  the semaphore, then the highest priority
37       thread that has been waiting the longest shall  be  unblocked.  If  the
38       Process  Scheduling  option  is  not defined, the choice of a thread to
39       unblock is unspecified.
40
41       If the Process Sporadic Server option is supported, and the  scheduling
42       policy is SCHED_SPORADIC, the semantics are as per SCHED_FIFO above.
43
44       The  sem_post() function shall be reentrant with respect to signals and
45       may be invoked from a signal-catching function.
46

RETURN VALUE

48       If successful, the sem_post() function shall  return  zero;  otherwise,
49       the function shall return -1 and set errno to indicate the error.
50

ERRORS

52       The sem_post() function shall fail if:
53
54       EINVAL The sem argument does not refer to a valid semaphore.
55
56
57       The following sections are informative.
58

EXAMPLES

60       None.
61

APPLICATION USAGE

63       The  sem_post()  function is part of the Semaphores option and need not
64       be available on all implementations.
65

RATIONALE

67       None.
68

FUTURE DIRECTIONS

70       None.
71

SEE ALSO

73       semctl(),   semget(),    semop(),    sem_timedwait(),    sem_trywait(),
74       sem_wait(), the Base Definitions volume of IEEE Std 1003.1-2001, <sema‐
75       phore.h>
76
78       Portions of this text are reprinted and reproduced in  electronic  form
79       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
80       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
81       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
82       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
83       event of any discrepancy between this version and the original IEEE and
84       The Open Group Standard, the original IEEE and The Open Group  Standard
85       is  the  referee document. The original Standard can be obtained online
86       at http://www.opengroup.org/unix/online.html .
87
88
89
90IEEE/The Open Group                  2003                         SEM_POST(3P)
Impressum