1SVIPC(7)                   Linux Programmer's Manual                  SVIPC(7)
2
3
4

NAME

6       svipc - System V interprocess communication mechanisms
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <sys/ipc.h>
11       #include <sys/msg.h>
12       #include <sys/sem.h>
13       #include <sys/shm.h>
14

DESCRIPTION

16       This  manual  page  refers  to the Linux implementation of the System V
17       interprocess communication (IPC) mechanisms: message queues,  semaphore
18       sets,  and shared memory segments.  In the following, the word resource
19       means an instantiation of one among such mechanisms.
20
21   Resource Access Permissions
22       For each resource, the system uses a common structure  of  type  struct
23       ipc_perm to store information needed in determining permissions to per‐
24       form  an  IPC  operation.   The  ipc_perm  structure,  defined  by  the
25       <sys/ipc.h> system header file, includes the following members:
26
27           struct ipc_perm {
28               uid_t          cuid;   /* creator user ID */
29               gid_t          cgid;   /* creator group ID */
30               uid_t          uid;    /* owner user ID */
31               gid_t          gid;    /* owner group ID */
32               unsigned short mode;   /* r/w permissions */
33           };
34
35       The  mode  member  of  the ipc_perm structure defines, with its lower 9
36       bits, the access permissions to the resource for a process executing an
37       IPC system call.  The permissions are interpreted as follows:
38
39           0400    Read by user.
40           0200    Write by user.
41           0040    Read by group.
42           0020    Write by group.
43           0004    Read by others.
44           0002    Write by others.
45
46       Bits  0100, 0010, and 0001 (the execute bits) are unused by the system.
47       Furthermore, "write" effectively means "alter" for a semaphore set.
48
49       The same system header file also defines the  following  symbolic  con‐
50       stants:
51
52       IPC_CREAT     Create entry if key doesn't exist.
53
54       IPC_EXCL      Fail if key exists.
55
56       IPC_NOWAIT    Error if request must wait.
57
58       IPC_PRIVATE   Private key.
59
60       IPC_RMID      Remove resource.
61
62       IPC_SET       Set resource options.
63
64       IPC_STAT      Get resource options.
65
66       Note  that  IPC_PRIVATE  is  a key_t type, while all the other symbolic
67       constants are flag fields and can be OR'ed into an int type variable.
68
69   Message Queues
70       A message queue is uniquely  identified  by  a  positive  integer  (its
71       msqid)  and  has  an associated data structure of type struct msqid_ds,
72       defined in <sys/msg.h>, containing the following members:
73
74           struct msqid_ds {
75               struct ipc_perm msg_perm;
76               msgqnum_t       msg_qnum;    /* no of messages on queue */
77               msglen_t        msg_qbytes;  /* bytes max on a queue */
78               pid_t           msg_lspid;   /* PID of last msgsnd(2) call */
79               pid_t           msg_lrpid;   /* PID of last msgrcv(2) call */
80               time_t          msg_stime;   /* last msgsnd(2) time */
81               time_t          msg_rtime;   /* last msgrcv(2) time */
82               time_t          msg_ctime;   /* last change time */
83           };
84
85       msg_perm   ipc_perm structure that specifies the access permissions  on
86                  the message queue.
87
88       msg_qnum   Number of messages currently on the message queue.
89
90       msg_qbytes Maximum  number of bytes of message text allowed on the mes‐
91                  sage queue.
92
93       msg_lspid  ID of the process that performed the last  msgsnd(2)  system
94                  call.
95
96       msg_lrpid  ID  of  the process that performed the last msgrcv(2) system
97                  call.
98
99       msg_stime  Time of the last msgsnd(2) system call.
100
101       msg_rtime  Time of the last msgrcv(2) system call.
102
103       msg_ctime  Time of the last system call that changed a  member  of  the
104                  msqid_ds structure.
105
106   Semaphore Sets
107       A  semaphore  set  is  uniquely  identified  by a positive integer (its
108       semid) and has an associated data structure of  type  struct  semid_ds,
109       defined in <sys/sem.h>, containing the following members:
110
111           struct semid_ds {
112               struct ipc_perm sem_perm;
113               time_t          sem_otime;   /* last operation time */
114               time_t          sem_ctime;   /* last change time */
115               unsigned long   sem_nsems;   /* count of sems in set */
116           };
117
118       sem_perm   ipc_perm  structure that specifies the access permissions on
119                  the semaphore set.
120
121       sem_otime  Time of last semop(2) system call.
122
123       sem_ctime  Time of last semctl(2) system call that changed a member  of
124                  the  above  structure  or  of one semaphore belonging to the
125                  set.
126
127       sem_nsems  Number of semaphores in the set.  Each semaphore of the  set
128                  is  referenced  by  a  nonnegative integer ranging from 0 to
129                  sem_nsems-1.
130
131       A semaphore is a data structure of type struct sem containing the  fol‐
132       lowing members:
133
134           struct sem {
135               int semval;  /* semaphore value */
136               int sempid;  /* PID for last operation */
137           };
138
139       semval     Semaphore value: a nonnegative integer.
140
141       sempid     ID  of the last process that performed a semaphore operation
142                  on this semaphore.
143
144   Shared Memory Segments
145       A shared memory segment is uniquely identified by  a  positive  integer
146       (its  shmid)  and  has  an  associated  data  structure  of type struct
147       shmid_ds, defined in <sys/shm.h>, containing the following members:
148
149           struct shmid_ds {
150               struct ipc_perm shm_perm;
151               size_t          shm_segsz;   /* size of segment */
152               pid_t           shm_cpid;    /* PID of creator */
153               pid_t           shm_lpid;    /* PID, last operation */
154               shmatt_t        shm_nattch;  /* no. of current attaches */
155               time_t          shm_atime;   /* time of last attach */
156               time_t          shm_dtime;   /* time of last detach */
157               time_t          shm_ctime;   /* time of last change */
158           };
159
160       shm_perm   ipc_perm structure that specifies the access permissions  on
161                  the shared memory segment.
162
163       shm_segsz  Size in bytes of the shared memory segment.
164
165       shm_cpid   ID of the process that created the shared memory segment.
166
167       shm_lpid   ID  of the last process that executed a shmat(2) or shmdt(2)
168                  system call.
169
170       shm_nattch Number of current alive attaches for this shared memory seg‐
171                  ment.
172
173       shm_atime  Time of the last shmat(2) system call.
174
175       shm_dtime  Time of the last shmdt(2) system call.
176
177       shm_ctime  Time   of  the  last  shmctl(2)  system  call  that  changed
178                  shmid_ds.
179

SEE ALSO

181       ipc(2),  msgctl(2),   msgget(2),   msgrcv(2),   msgsnd(2),   semctl(2),
182       semget(2), semop(2), shmat(2), shmctl(2), shmdt(2), shmget(2), ftok(3)
183

COLOPHON

185       This  page  is  part of release 3.25 of the Linux man-pages project.  A
186       description of the project, and information about reporting  bugs,  can
187       be found at http://www.kernel.org/doc/man-pages/.
188
189
190
191Linux                             2009-01-26                          SVIPC(7)
Impressum