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
11

NAME

13       sem_post — unlock a semaphore
14

SYNOPSIS

16       #include <semaphore.h>
17
18       int sem_post(sem_t *sem);
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 async-signal-safe and may be invoked
45       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 may fail if:
53
54       EINVAL The sem argument does not refer to a valid semaphore.
55
56       The following sections are informative.
57

EXAMPLES

59       See sem_timedwait().
60

APPLICATION USAGE

62       None.
63

RATIONALE

65       None.
66

FUTURE DIRECTIONS

68       None.
69

SEE ALSO

71       semctl(), semget(), semop(), sem_timedwait(), sem_trywait()
72
73       The  Base Definitions volume of POSIX.1‐2008, Section 4.11, Memory Syn‐
74       chronization, <semaphore.h>
75
77       Portions of this text are reprinted and reproduced in  electronic  form
78       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
79       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
80       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
81       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
82       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) 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.unix.org/online.html .
87
88       Any  typographical  or  formatting  errors that appear in this page are
89       most likely to have been introduced during the conversion of the source
90       files  to  man page format. To report such errors, see https://www.ker
91       nel.org/doc/man-pages/reporting_bugs.html .
92
93
94
95IEEE/The Open Group                  2013                         SEM_POST(3P)
Impressum