1sem_post(3C)             Standard C Library Functions             sem_post(3C)
2
3
4

NAME

6       sem_post - increment the count of a semaphore
7

SYNOPSIS

9       #include <semaphore.h>
10
11       int sem_post(sem_t *sem);
12
13

DESCRIPTION

15       The sem_post() function unlocks the semaphore referenced by sem by per‐
16       forming a semaphore unlock operation on that semaphore.
17
18
19       If the semaphore value resulting from this operation is positive,  then
20       no  threads  were blocked waiting for the semaphore to become unlocked;
21       the semaphore value is simply incremented.
22
23
24       If the value of the semaphore resulting from this operation is 0,  then
25       one  of  the threads  blocked waiting for the semaphore will be allowed
26       to return successfully from its call to  sem_wait(3C).  If  the  symbol
27       _POSIX_PRIORITY_SCHEDULING is defined, the thread  to be unblocked will
28       be chosen in a manner appropriate to the scheduling policies and param‐
29       eters  in effect for the blocked threads. In the case of the schedulers
30       SCHED_FIFO and SCHED_RR, the highest priority waiting thread   will  be
31       unblocked,  and  if  there  is  more  than  one highest priority thread
32       blocked waiting for the semaphore, then  the  highest  priority  thread
33       that  has  been  waiting  the  longest will be unblocked. If the symbol
34       _POSIX_PRIORITY_SCHEDULING is not defined, the choice of a  thread   to
35       unblock is unspecified.
36

RETURN VALUES

38       If  successful,  sem_post() returns 0; otherwise it returns −1 and sets
39       errno to indicate the error.
40

ERRORS

42       The sem_post() function will fail if:
43
44       EINVAL        The sem argument does not refer to a valid semaphore.
45
46
47       ENOSYS        The sem_post() function is not supported by the system.
48
49
50       EOVERFLOW     The semaphore value exceeds SEM_VALUE_MAX.
51
52

USAGE

54       The sem_post() function is reentrant with respect to signals and may be
55       invoked  from  a  signal-catching function. The semaphore functionality
56       described on this manual page  is  for  the  POSIX  (see  standards(5))
57       threads  implementation.  For  the documentation of the Solaris threads
58       interface, see semaphore(3C)).
59

EXAMPLES

61       See sem_wait(3C).
62

ATTRIBUTES

64       See attributes(5) for descriptions of the following attributes:
65
66
67
68
69       ┌─────────────────────────────┬─────────────────────────────┐
70       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
71       ├─────────────────────────────┼─────────────────────────────┤
72       │Interface Stability          │Committed                    │
73       ├─────────────────────────────┼─────────────────────────────┤
74       │MT-Level                     │Async-Signal-Safe            │
75       ├─────────────────────────────┼─────────────────────────────┤
76       │Standard                     │See standards(5).            │
77       └─────────────────────────────┴─────────────────────────────┘
78

SEE ALSO

80       sched_setscheduler(3C),  sem_wait(3C),  semaphore(3C),   attributes(5),
81       standards(5)
82
83
84
85SunOS 5.11                        5 Feb 2008                      sem_post(3C)
Impressum