1sys_sem.h(0P) POSIX Programmer's Manual sys_sem.h(0P)
2
3
4
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
13 sys/sem.h — XSI semaphore facility
14
16 #include <sys/sem.h>
17
19 The <sys/sem.h> header shall define the following symbolic constant for
20 use as a semaphore operation flag:
21
22 SEM_UNDO Set up adjust on exit entry.
23
24 The <sys/sem.h> header shall define the following symbolic constants
25 for use as commands for the semctl() function:
26
27 GETNCNT Get semncnt.
28
29 GETPID Get sempid.
30
31 GETVAL Get semval.
32
33 GETALL Get all cases of semval.
34
35 GETZCNT Get semzcnt.
36
37 SETVAL Set semval.
38
39 SETALL Set all cases of semval.
40
41 The <sys/sem.h> header shall define the semid_ds structure, which shall
42 include the following members:
43
44 struct ipc_perm sem_perm Operation permission structure.
45 unsigned short sem_nsems Number of semaphores in set.
46 time_t sem_otime Last semop() time.
47 time_t sem_ctime Last time changed by semctl().
48
49 The <sys/sem.h> header shall define the pid_t, size_t, and time_t types
50 as described in <sys/types.h>.
51
52 A semaphore shall be represented by an anonymous structure, which shall
53 include the following members:
54
55 unsigned short semval Semaphore value.
56 pid_t sempid Process ID of last operation.
57 unsigned short semncnt Number of processes waiting for semval
58 to become greater than current value.
59 unsigned short semzcnt Number of processes waiting for semval
60 to become 0.
61
62 The <sys/sem.h> header shall define the sembuf structure, which shall
63 include the following members:
64
65 unsigned short sem_num Semaphore number.
66 short sem_op Semaphore operation.
67 short sem_flg Operation flags.
68
69 The following shall be declared as functions and may also be defined as
70 macros. Function prototypes shall be provided.
71
72 int semctl(int, int, int, ...);
73 int semget(key_t, int, int);
74 int semop(int, struct sembuf *, size_t);
75
76 In addition, the <sys/sem.h> header shall include the <sys/ipc.h>
77 header.
78
79 The following sections are informative.
80
82 None.
83
85 None.
86
88 None.
89
91 <sys_ipc.h>, <sys_types.h>
92
93 The System Interfaces volume of POSIX.1‐2008, semctl(), semget(),
94 semop()
95
97 Portions of this text are reprinted and reproduced in electronic form
98 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
99 -- Portable Operating System Interface (POSIX), The Open Group Base
100 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
101 cal and Electronics Engineers, Inc and The Open Group. (This is
102 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
103 event of any discrepancy between this version and the original IEEE and
104 The Open Group Standard, the original IEEE and The Open Group Standard
105 is the referee document. The original Standard can be obtained online
106 at http://www.unix.org/online.html .
107
108 Any typographical or formatting errors that appear in this page are
109 most likely to have been introduced during the conversion of the source
110 files to man page format. To report such errors, see https://www.ker‐
111 nel.org/doc/man-pages/reporting_bugs.html .
112
113
114
115IEEE/The Open Group 2013 sys_sem.h(0P)