version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
IPC |
|
|
2 |
!!!IPC |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
SEE ALSO |
|
|
7 |
---- |
|
|
8 |
!!NAME |
|
|
9 |
|
|
|
10 |
|
|
|
11 |
ipc - System V interprocess communication mechanisms |
|
|
12 |
!!SYNOPSIS |
|
|
13 |
|
|
|
14 |
|
|
|
15 |
__# include |
|
|
16 |
__ |
|
|
17 |
!!DESCRIPTION |
|
|
18 |
|
|
|
19 |
|
|
|
20 |
The manual page refers to the Linux implementation of the |
|
|
21 |
System V interprocess communication mechanisms: message |
|
|
22 |
queues, semaphore sets and shared memory segments. In the |
|
|
23 |
following, the word __resource__ means an instantiation |
|
|
24 |
of one among such mechanisms. |
|
|
25 |
|
|
|
26 |
|
|
|
27 |
__Resource Access Permissions__ |
|
|
28 |
|
|
|
29 |
|
|
|
30 |
For each resource the system uses a common structure of type |
|
|
31 |
__struct ipc_perm__ to store information needed in |
|
|
32 |
determining permissions to perform an ipc operation. The |
|
|
33 |
__ipc_perm__ structure, defined by the |
|
|
34 |
'''' system header file, includes the |
|
|
35 |
following members: |
|
|
36 |
|
|
|
37 |
|
|
|
38 |
__ushort cuid;__ /* creator user id */__ |
|
|
39 |
ushort cgid;__ /* creator group id */__ |
|
|
40 |
ushort uid;__ /* owner user id */__ |
|
|
41 |
ushort gid;__ /* owner group id */__ |
|
|
42 |
ushort mode;__ /* r/w permissions */ |
|
|
43 |
|
|
|
44 |
|
|
|
45 |
The __mode__ member of the __ipc_perm__ structure |
|
|
46 |
defines, with its lower 9 bits, the access permissions to |
|
|
47 |
the resource for a process executing an ipc system call. The |
|
|
48 |
permissions are interpreted as follows: |
|
|
49 |
|
|
|
50 |
|
|
|
51 |
0400 Read by user. |
|
|
52 |
0200 Write by user. |
|
|
53 |
0040 Read by group. |
|
|
54 |
0020 Write by group. |
|
|
55 |
0004 Read by others. |
|
|
56 |
0002 Write by others. |
|
|
57 |
Bits 0100, 0010 and 0001 (the execute bits) are unused by the system. Furthermore |
|
|
58 |
|
|
|
59 |
|
|
|
60 |
The same system header file defines also the following |
|
|
61 |
symbolic constants: |
|
|
62 |
|
|
|
63 |
|
|
|
64 |
__IPC_CREAT__ |
|
|
65 |
|
|
|
66 |
|
|
|
67 |
Create entry if key doesn't exists. |
|
|
68 |
|
|
|
69 |
|
|
|
70 |
__IPC_EXCL__ |
|
|
71 |
|
|
|
72 |
|
|
|
73 |
Fail if key exists. |
|
|
74 |
|
|
|
75 |
|
|
|
76 |
__IPC_NOWAIT__ |
|
|
77 |
|
|
|
78 |
|
|
|
79 |
Error if request must wait. |
|
|
80 |
|
|
|
81 |
|
|
|
82 |
__IPC_PRIVATE__ |
|
|
83 |
|
|
|
84 |
|
|
|
85 |
Private key. |
|
|
86 |
|
|
|
87 |
|
|
|
88 |
__IPC_RMID__ |
|
|
89 |
|
|
|
90 |
|
|
|
91 |
Remove resource. |
|
|
92 |
|
|
|
93 |
|
|
|
94 |
__IPC_SET__ |
|
|
95 |
|
|
|
96 |
|
|
|
97 |
Set resource options. |
|
|
98 |
|
|
|
99 |
|
|
|
100 |
__IPC_STAT__ |
|
|
101 |
|
|
|
102 |
|
|
|
103 |
Get resource options. |
|
|
104 |
|
|
|
105 |
|
|
|
106 |
Note that __IPC_PRIVATE__ is a __key_t__ type, while |
|
|
107 |
all the others symbolic constants are flag fields or-able |
|
|
108 |
into an __int__ type variable. |
|
|
109 |
|
|
|
110 |
|
|
|
111 |
__Message Queues__ |
|
|
112 |
|
|
|
113 |
|
|
|
114 |
A message queue is uniquely identified by a positive integer |
|
|
115 |
(its ''msqid'') and has an associated data structure of |
|
|
116 |
type __struct msquid_ds__, defined in |
|
|
117 |
'''', containing the following |
|
|
118 |
members: |
|
|
119 |
|
|
|
120 |
|
|
|
121 |
__struct ipc_perm msg_perm; |
|
|
122 |
ushort msg_qnum;__ /* no of messages on queue */__ |
|
|
123 |
ushort msg_qbytes;__ /* bytes max on a queue */__ |
|
|
124 |
ushort msg_lspid;__ /* pid of last msgsnd call */__ |
|
|
125 |
ushort msg_lrpid;__ /* pid of last msgrcv call */__ |
|
|
126 |
time_t msg_stime;__ /* last msgsnd time */__ |
|
|
127 |
time_t msg_rtime;__ /* last msgrcv time */__ |
|
|
128 |
time_t msg_ctime;__ /* last change time */ |
|
|
129 |
|
|
|
130 |
|
|
|
131 |
__msg_perm__ |
|
|
132 |
|
|
|
133 |
|
|
|
134 |
__ipc_perm__ structure that specifies the access |
|
|
135 |
permissions on the message queue. |
|
|
136 |
|
|
|
137 |
|
|
|
138 |
__msg_qnum__ |
|
|
139 |
|
|
|
140 |
|
|
|
141 |
Number of messages currently on the message |
|
|
142 |
queue. |
|
|
143 |
|
|
|
144 |
|
|
|
145 |
__msg_qbytes__ |
|
|
146 |
|
|
|
147 |
|
|
|
148 |
Maximum number of bytes of message text allowed on the |
|
|
149 |
message queue. |
|
|
150 |
|
|
|
151 |
|
|
|
152 |
__msg_lspid__ |
|
|
153 |
|
|
|
154 |
|
|
|
155 |
ID of the process that performed the last __msgsnd__ |
|
|
156 |
system call. |
|
|
157 |
|
|
|
158 |
|
|
|
159 |
__msg_lrpid__ |
|
|
160 |
|
|
|
161 |
|
|
|
162 |
ID of the process that performed the last __msgrcv__ |
|
|
163 |
system call. |
|
|
164 |
|
|
|
165 |
|
|
|
166 |
__msg_stime__ |
|
|
167 |
|
|
|
168 |
|
|
|
169 |
Time of the last __msgsnd__ system call. |
|
|
170 |
|
|
|
171 |
|
|
|
172 |
__msg_rtime__ |
|
|
173 |
|
|
|
174 |
|
|
|
175 |
Time of the last __msgcv__ system call. |
|
|
176 |
|
|
|
177 |
|
|
|
178 |
__msg_ctime__ |
|
|
179 |
|
|
|
180 |
|
|
|
181 |
Time of the last system call that changed a member of the |
|
|
182 |
__msqid_ds__ structure. |
|
|
183 |
|
|
|
184 |
|
|
|
185 |
__Semaphore Sets__ |
|
|
186 |
|
|
|
187 |
|
|
|
188 |
A semaphore set is uniquely identified by a positive integer |
|
|
189 |
(its ''semid'') and has an associated data structure of |
|
|
190 |
type __struct semid_ds__, defined in |
|
|
191 |
'''', containing the following |
|
|
192 |
members: |
|
|
193 |
|
|
|
194 |
|
|
|
195 |
__struct ipc_perm sem_perm; |
|
|
196 |
time_t sem_otime;__ /* last operation time */__ |
|
|
197 |
time_t sem_ctime;__ /* last change time */__ |
|
|
198 |
ushort sem_nsems;__ /* count of sems in set |
|
|
199 |
*/ |
|
|
200 |
|
|
|
201 |
|
|
|
202 |
__sem_perm__ |
|
|
203 |
|
|
|
204 |
|
|
|
205 |
__ipc_perm__ structure that specifies the access |
|
|
206 |
permissions on the semaphore set. |
|
|
207 |
|
|
|
208 |
|
|
|
209 |
__sem_otime__ |
|
|
210 |
|
|
|
211 |
|
|
|
212 |
Time of last __semop__ system call. |
|
|
213 |
|
|
|
214 |
|
|
|
215 |
__sem_ctime__ |
|
|
216 |
|
|
|
217 |
|
|
|
218 |
Time of last __semctl__ system call that changed a member |
|
|
219 |
of the above structure or of one semaphore belonging to the |
|
|
220 |
set. |
|
|
221 |
|
|
|
222 |
|
|
|
223 |
__sem_nsems__ |
|
|
224 |
|
|
|
225 |
|
|
|
226 |
Number of semaphores in the set. Each semaphore of the set |
|
|
227 |
is referenced by a non-negative integer ranging from |
|
|
228 |
__0__ to __sem_nsems-1__. |
|
|
229 |
|
|
|
230 |
|
|
|
231 |
A semaphore is a data structure of type __struct sem__ |
|
|
232 |
containing the following members: |
|
|
233 |
|
|
|
234 |
|
|
|
235 |
__ushort semval;__ /* semaphore value */__ |
|
|
236 |
short sempid;__ /* pid for last operation */__ |
|
|
237 |
ushort semncnt;__ /* no. of awaiting semval to increase |
|
|
238 |
*/__ |
|
|
239 |
ushort semzcnt;__ /* no. of awaiting semval = 0 |
|
|
240 |
*/ |
|
|
241 |
|
|
|
242 |
|
|
|
243 |
__semval__ |
|
|
244 |
|
|
|
245 |
|
|
|
246 |
Semaphore value: a non-negative integer. |
|
|
247 |
|
|
|
248 |
|
|
|
249 |
__sempid__ |
|
|
250 |
|
|
|
251 |
|
|
|
252 |
ID of the last process that performed a semaphore operation |
|
|
253 |
on this semaphore. |
|
|
254 |
|
|
|
255 |
|
|
|
256 |
__semncnt__ |
|
|
257 |
|
|
|
258 |
|
|
|
259 |
Number of processes suspended awaiting for __semval__ to |
|
|
260 |
increase. |
|
|
261 |
|
|
|
262 |
|
|
|
263 |
__semznt__ |
|
|
264 |
|
|
|
265 |
|
|
|
266 |
Number of processes suspended awaiting for __semval__ to |
|
|
267 |
become zero. |
|
|
268 |
|
|
|
269 |
|
|
|
270 |
__Shared Memory Segments__ |
|
|
271 |
|
|
|
272 |
|
|
|
273 |
A shared memory segment is uniquely identified by a positive |
|
|
274 |
integer (its ''shmid'') and has an associated data |
|
|
275 |
structure of type __struct shmid_ds__, defined in |
|
|
276 |
'''', containing the following |
|
|
277 |
members: |
|
|
278 |
|
|
|
279 |
|
|
|
280 |
__struct ipc_perm shm_perm; |
|
|
281 |
int shm_segsz;__ /* size of segment */__ |
|
|
282 |
ushort shm_cpid;__ /* pid of creator */__ |
|
|
283 |
ushort shm_lpid;__ /* pid, last operation */__ |
|
|
284 |
short shm_nattch;__ /* no. of current attaches */__ |
|
|
285 |
time_t shm_atime;__ /* time of last attach */__ |
|
|
286 |
time_t shm_dtime;__ /* time of last detach */__ |
|
|
287 |
time_t shm_ctime;__ /* time of last change */ |
|
|
288 |
|
|
|
289 |
|
|
|
290 |
__shm_perm__ |
|
|
291 |
|
|
|
292 |
|
|
|
293 |
__ipc_perm__ structure that specifies the access |
|
|
294 |
permissions on the shared memory segment. |
|
|
295 |
|
|
|
296 |
|
|
|
297 |
__shm_segsz__ |
|
|
298 |
|
|
|
299 |
|
|
|
300 |
Size in bytes of the shared memory segment. |
|
|
301 |
|
|
|
302 |
|
|
|
303 |
__shm_cpid__ |
|
|
304 |
|
|
|
305 |
|
|
|
306 |
ID of the process that created the shared memory |
|
|
307 |
segment. |
|
|
308 |
|
|
|
309 |
|
|
|
310 |
__shm_lpid__ |
|
|
311 |
|
|
|
312 |
|
|
|
313 |
ID of the last process that executed a __shmat__ or |
|
|
314 |
__shmdt__ system call. |
|
|
315 |
|
|
|
316 |
|
|
|
317 |
__shm_nattch__ |
|
|
318 |
|
|
|
319 |
|
|
|
320 |
Number of current alive attaches for this shared memory |
|
|
321 |
segment. |
|
|
322 |
|
|
|
323 |
|
|
|
324 |
__shm_atime__ |
|
|
325 |
|
|
|
326 |
|
|
|
327 |
Time of the last __shmat__ system call. |
|
|
328 |
|
|
|
329 |
|
|
|
330 |
__shm_dtime__ |
|
|
331 |
|
|
|
332 |
|
|
|
333 |
Time of the last __shmdt__ system call. |
|
|
334 |
|
|
|
335 |
|
|
|
336 |
__shm_ctime__ |
|
|
337 |
|
|
|
338 |
|
|
|
339 |
Time of the last __shmctl__ system call that changed |
|
|
340 |
__shmid_ds__. |
|
|
341 |
!!SEE ALSO |
|
|
342 |
|
|
|
343 |
|
|
|
344 |
ftok(3), msgctl(2), msgget(2), |
|
|
345 |
msgrcv(2), msgsnd(2), semctl(2), |
|
|
346 |
semget(2), semop(2), shmat(2), |
|
|
347 |
shmctl(2), shmget(2), |
|
|
348 |
shmdt(2) |
|
|
349 |
---- |