OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / original / man7 / svipc.7
1 .\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" FIXME There is now duplication of some of the information
24 .\" below in semctl.2, msgctl.2, and shmctl.2 -- MTK, Nov 04
25 .TH SVIPC 7 2009-01-26 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 svipc \- System V interprocess communication mechanisms
28 .SH SYNOPSIS
29 .nf
30 .B #include <sys/types.h>
31 .B #include <sys/ipc.h>
32 .B #include <sys/msg.h>
33 .B #include <sys/sem.h>
34 .B #include <sys/shm.h>
35 .fi
36 .SH DESCRIPTION
37 This manual page refers to the Linux implementation of the System V
38 interprocess communication (IPC) mechanisms:
39 message queues, semaphore sets, and shared memory segments.
40 In the following, the word
41 .I resource
42 means an instantiation of one among such mechanisms.
43 .SS Resource Access Permissions
44 For each resource, the system uses a common structure of type
45 .I "struct ipc_perm"
46 to store information needed in determining permissions to perform an
47 IPC operation.
48 The
49 .I ipc_perm
50 structure, defined by the
51 .I <sys/ipc.h>
52 system header file, includes the following members:
53 .in +4n
54 .nf
55
56 struct ipc_perm {
57     uid_t          cuid;   /* creator user ID */
58     gid_t          cgid;   /* creator group ID */
59     uid_t          uid;    /* owner user ID */
60     gid_t          gid;    /* owner group ID */
61     unsigned short mode;   /* r/w permissions */
62 };
63 .fi
64 .in
65 .PP
66 The
67 .I mode
68 member of the
69 .I ipc_perm
70 structure defines, with its lower 9 bits, the access permissions to the
71 resource for a process executing an IPC system call.
72 The permissions are interpreted as follows:
73 .sp
74 .nf
75     0400    Read by user.
76     0200    Write by user.
77 .sp .5
78     0040    Read by group.
79     0020    Write by group.
80 .sp .5
81     0004    Read by others.
82     0002    Write by others.
83 .fi
84 .PP
85 Bits 0100, 0010, and 0001 (the execute bits) are unused by the system.
86 Furthermore,
87 "write"
88 effectively means
89 "alter"
90 for a semaphore set.
91 .PP
92 The same system header file also defines the following symbolic
93 constants:
94 .TP 14
95 .B IPC_CREAT
96 Create entry if key doesn't exist.
97 .TP
98 .B IPC_EXCL
99 Fail if key exists.
100 .TP
101 .B IPC_NOWAIT
102 Error if request must wait.
103 .TP
104 .B IPC_PRIVATE
105 Private key.
106 .TP
107 .B IPC_RMID
108 Remove resource.
109 .TP
110 .B IPC_SET
111 Set resource options.
112 .TP
113 .B IPC_STAT
114 Get resource options.
115 .PP
116 Note that
117 .B IPC_PRIVATE
118 is a
119 .I key_t
120 type, while all the other symbolic constants are flag fields and can
121 be OR'ed into an
122 .I int
123 type variable.
124 .SS Message Queues
125 A message queue is uniquely identified by a positive integer
126 .RI "(its " msqid )
127 and has an associated data structure of type
128 .IR "struct msqid_ds" ,
129 defined in
130 .IR <sys/msg.h> ,
131 containing the following members:
132 .in +4n
133 .nf
134
135 struct msqid_ds {
136     struct ipc_perm msg_perm;
137     msgqnum_t       msg_qnum;    /* no of messages on queue */
138     msglen_t        msg_qbytes;  /* bytes max on a queue */
139     pid_t           msg_lspid;   /* PID of last msgsnd(2) call */
140     pid_t           msg_lrpid;   /* PID of last msgrcv(2) call */
141     time_t          msg_stime;   /* last msgsnd(2) time */
142     time_t          msg_rtime;   /* last msgrcv(2) time */
143     time_t          msg_ctime;   /* last change time */
144 };
145 .fi
146 .in
147 .TP 11
148 .I msg_perm
149 .I ipc_perm
150 structure that specifies the access permissions on the message
151 queue.
152 .TP
153 .I msg_qnum
154 Number of messages currently on the message queue.
155 .TP
156 .I msg_qbytes
157 Maximum number of bytes of message text allowed on the message
158 queue.
159 .TP
160 .I msg_lspid
161 ID of the process that performed the last
162 .BR msgsnd (2)
163 system call.
164 .TP
165 .I msg_lrpid
166 ID of the process that performed the last
167 .BR msgrcv (2)
168 system call.
169 .TP
170 .I msg_stime
171 Time of the last
172 .BR msgsnd (2)
173 system call.
174 .TP
175 .I msg_rtime
176 Time of the last
177 .BR msgrcv (2)
178 system call.
179 .TP
180 .I msg_ctime
181 Time of the last
182 system call that changed a member of the
183 .I msqid_ds
184 structure.
185 .SS Semaphore Sets
186 A semaphore set is uniquely identified by a positive integer
187 .RI "(its " semid )
188 and has an associated data structure of type
189 .IR "struct semid_ds" ,
190 defined in
191 .IR <sys/sem.h> ,
192 containing the following members:
193 .in +4n
194 .nf
195
196 struct semid_ds {
197     struct ipc_perm sem_perm;
198     time_t          sem_otime;   /* last operation time */
199     time_t          sem_ctime;   /* last change time */
200     unsigned long   sem_nsems;   /* count of sems in set */
201 };
202 .fi
203 .in
204 .TP 11
205 .I sem_perm
206 .I ipc_perm
207 structure that specifies the access permissions on the semaphore
208 set.
209 .TP
210 .I sem_otime
211 Time of last
212 .BR semop (2)
213 system call.
214 .TP
215 .I sem_ctime
216 Time of last
217 .BR semctl (2)
218 system call that changed a member of the above structure or of one
219 semaphore belonging to the set.
220 .TP
221 .I sem_nsems
222 Number of semaphores in the set.
223 Each semaphore of the set is referenced by a nonnegative integer
224 ranging from
225 .B 0
226 to
227 .IR sem_nsems\-1 .
228 .PP
229 A semaphore is a data structure of type
230 .I "struct sem"
231 containing the following members:
232 .in +4n
233 .nf
234
235 struct sem {
236     int semval;  /* semaphore value */
237     int sempid;  /* PID for last operation */
238 .\"    unsigned short semncnt; /* nr awaiting semval to increase */
239 .\"    unsigned short semzcnt; /* nr awaiting semval = 0 */
240 };
241 .fi
242 .in
243 .TP 11
244 .I semval
245 Semaphore value: a nonnegative integer.
246 .TP
247 .I sempid
248 ID of the last process that performed a semaphore operation
249 on this semaphore.
250 .\".TP
251 .\".I semncnt
252 .\"Number of processes suspended awaiting for
253 .\".I semval
254 .\"to increase.
255 .\".TP
256 .\".I semznt
257 .\"Number of processes suspended awaiting for
258 .\".I semval
259 .\"to become zero.
260 .SS Shared Memory Segments
261 A shared memory segment is uniquely identified by a positive integer
262 .RI "(its " shmid )
263 and has an associated data structure of type
264 .IR "struct shmid_ds" ,
265 defined in
266 .IR <sys/shm.h> ,
267 containing the following members:
268 .in +4n
269 .nf
270
271 struct shmid_ds {
272     struct ipc_perm shm_perm;
273     size_t          shm_segsz;   /* size of segment */
274     pid_t           shm_cpid;    /* PID of creator */
275     pid_t           shm_lpid;    /* PID, last operation */
276     shmatt_t        shm_nattch;  /* no. of current attaches */
277     time_t          shm_atime;   /* time of last attach */
278     time_t          shm_dtime;   /* time of last detach */
279     time_t          shm_ctime;   /* time of last change */
280 };
281 .fi
282 .in
283 .TP 11
284 .I shm_perm
285 .I ipc_perm
286 structure that specifies the access permissions on the shared memory
287 segment.
288 .TP
289 .I shm_segsz
290 Size in bytes of the shared memory segment.
291 .TP
292 .I shm_cpid
293 ID of the process that created the shared memory segment.
294 .TP
295 .I shm_lpid
296 ID of the last process that executed a
297 .BR shmat (2)
298 or
299 .BR shmdt (2)
300 system call.
301 .TP
302 .I shm_nattch
303 Number of current alive attaches for this shared memory segment.
304 .TP
305 .I shm_atime
306 Time of the last
307 .BR shmat (2)
308 system call.
309 .TP
310 .I shm_dtime
311 Time of the last
312 .BR shmdt (2)
313 system call.
314 .TP
315 .I shm_ctime
316 Time of the last
317 .BR shmctl (2)
318 system call that changed
319 .IR shmid_ds .
320 .SH "SEE ALSO"
321 .BR ipc (2),
322 .BR msgctl (2),
323 .BR msgget (2),
324 .BR msgrcv (2),
325 .BR msgsnd (2),
326 .BR semctl (2),
327 .BR semget (2),
328 .BR semop (2),
329 .BR shmat (2),
330 .BR shmctl (2),
331 .BR shmdt (2),
332 .BR shmget (2),
333 .BR ftok (3)