Penguin
Annotated edit history of semget(2) version 1, including all changes. View license author blame.
Rev Author # Line
1 perry 1 SEMGET
2 !!!SEMGET
3 NAME
4 SYNOPSIS
5 DESCRIPTION
6 RETURN VALUE
7 ERRORS
8 NOTES
9 BUGS
10 CONFORMING TO
11 SEE ALSO
12 ----
13 !!NAME
14
15
16 semget - get a semaphore set identifier
17 !!SYNOPSIS
18
19
20 __# include
21 ____int semget ( key_t__ ''key''__, int__ ''nsems''__, int__ ''semflg'' __)__
22 !!DESCRIPTION
23
24
25 The function returns the semaphore set identifier associated
26 to the value of the argument ''key''. A new set of
27 ''nsems'' semaphores is created if ''key'' has value
28 __IPC_PRIVATE__ or ''key'' isn't __IPC_PRIVATE__,
29 no existing semaphore set is associated to ''key'', and
30 __IPC_CREAT__ is asserted in ''semflg'' (i.e.
31 ''semflg'' ''IPC_CREAT__ isn't zero). The
32 presence in ''semflg'' of the fields __IPC_CREAT__ and
33 __IPC_EXCL__ plays the same role, with respect to the
34 existence of the semaphore set, as the presence of
35 __O_CREAT__ and __O_EXCL__ in the mode argument of the
36 open(2) system call: i.e. the __semget__ function
37 fails if ''semflg'' asserts both __IPC_CREAT__ and
38 __IPC_EXCL__ and a semaphore set already exists for
39 ''key''.
40
41
42 Upon creation, the lower 9 bits of the argument
43 ''semflg'' define the access permissions (for owner,
44 group and others) to the semaphore set in the same format,
45 and with the same meaning, as for the access permissions
46 parameter in the open(2) or creat(2) system
47 calls (though the execute permissions are not used by the
48 system, and write permissions, for a semaphore set,
49 effectively means alter permissions).
50
51
52 Furthermore, while creating, the system call initializes the
53 system semaphore set data structure __semid_ds__ as
54 follows:
55
56
57 __sem_perm.cuid__ and __sem_perm.uid__ are set to the
58 effective user-ID of the calling process.
59
60
61 __sem_perm.cgid__ and __sem_perm.gid__ are set to the
62 effective group-ID of the calling process.
63
64
65 The lowest order 9 bits of __sem_perm.mode__ are set to
66 the lowest order 9 bit of ''semflg''.
67
68
69 __sem_nsems__ is set to the value of
70 ''nsems''.
71
72
73 __sem_otime__ is set to 0.
74
75
76 __sem_ctime__ is set to the current time.
77
78
79 The argument ''nsems'' can be __0__ (a don't care)
80 when the system call isn't a create one. Otherwise
81 ''nsems'' must be greater than __0__ and less or equal
82 to the maximum number of semaphores per semid,
83 (__SEMMSL__).
84
85
86 If the semaphore set already exists, the access permissions
87 are verified, and a check is made to see if it is marked for
88 destruction.
89 !!RETURN VALUE
90
91
92 If successful, the return value will be the semaphore set
93 identifier (a positive integer), otherwise __-1__ with
94 __errno__ indicating the error.
95 !!ERRORS
96
97
98 For a failing return, __errno__ will be set to one among
99 the following values:
100
101
102 __EACCES__
103
104
105 A semaphore set exists for ''key'', but the calling
106 process has no access permissions to the set.
107
108
109 __EEXIST__
110
111
112 A semaphore set exists for __key__ and ''semflg'' was
113 asserting both __IPC_CREAT__ and
114 __IPC_EXCL__.
115
116
117 __EIDRM__
118
119
120 The semaphore set is marked as to be deleted.
121
122
123 __ENOENT__
124
125
126 No semaphore set exists for ''key'' and ''semflg''
127 wasn't asserting __IPC_CREAT__.
128
129
130 __ENOMEM__
131
132
133 A semaphore set has to be created but the system has not
134 enough memory for the new data structure.
135
136
137 __ENOSPC__
138
139
140 A semaphore set has to be created but the system limit for
141 the maximum number of semaphore sets (__SEMMNI__), or the
142 system wide maximum number of semaphores (__SEMMNS__),
143 would be exceeded.
144 !!NOTES
145
146
147 __IPC_PRIVATE__ isn't a flag field but a __key_t__
148 type. If this special value is used for ''key'', the
149 system call ignores everything but the lowest order 9 bits
150 of ''semflg'' and creates a new semaphore set (on
151 success).
152
153
154 The followings are limits on semaphore set resources
155 affecting a __semget__ call:
156
157
158 __SEMMNI__
159
160
161 System wide maximum number of semaphore sets: policy
162 dependent.
163
164
165 __SEMMSL__
166
167
168 Maximum number of semaphores per semid: implementation
169 dependent (500 currently).
170
171
172 __SEMMNS__
173
174
175 System wide maximum number of semaphores: policy dependent.
176 Values greater than __SEMMSL * SEMMNI__ makes it
177 irrelevant.
178 !!BUGS
179
180
181 Use of __IPC_PRIVATE__ doesn't inhibit to other processes
182 the access to the allocated semaphore set.
183
184
185 As for the files, there is currently no intrinsic way for a
186 process to ensure exclusive access to a semaphore set.
187 Asserting both __IPC_CREAT__ and __IPC_EXCL__ in
188 ''semflg'' only ensures (on success) that a new semaphore
189 set will be created, it doesn't imply exclusive access to
190 the semaphore set.
191
192
193 The data structure associated with each semaphore in the set
194 isn't initialized by the system call. In order to initialize
195 those data structures, one has to execute a subsequent call
196 to semctl(2) to perform a __SETVAL__ or a
197 __SETALL__ command on the semaphore set.
198 !!CONFORMING TO
199
200
201 SVr4, SVID. SVr4 documents additional error conditions
202 EINVAL, EFBIG, E2BIG, EAGAIN, ERANGE, EFAULT.
203 !!SEE ALSO
204
205
206 ftok(3), ipc(5), semctl(2),
207 semop(2)
208 ----
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.