The manual page refers to the Linux implementation of the System V interprocess communication mechanisms: message queues, semaphore sets and shared memory segments. In the following, the word resource means an instantiation of one among such mechanisms.
Resource Access Permissions
For each resource the system uses a common structure of type struct ipc_perm to store information needed in determining permissions to perform an ipc operation. The ipc_perm structure, defined by the system header file, includes the following members:
ushort cuid; /* creator user id / ushort cgid; / creator group id / ushort uid; / owner user id / ushort gid; / owner group id / ushort mode; / r/w permissions */
0200 Write by user. 0040 Read by group. 0020 Write by group. 0004 Read by others. 0002 Write by others. Bits 0100, 0010 and 0001 (the execute bits) are unused by the system. Furthermore
The same system header file defines also the following symbolic constants:
Create entry if key doesn't exists.
Fail if key exists.
Error if request must wait.
Set resource options.
Get resource options.
Note that IPC_PRIVATE is a key_t type, while all the others symbolic constants are flag fields or-able into an int type variable.
A message queue is uniquely identified by a positive integer (its msqid) and has an associated data structure of type struct msquid_ds, defined in , containing the following members:
struct ipc_perm msg_perm; ushort msg_qnum; /* no of messages on queue / ushort msg_qbytes; / bytes max on a queue / ushort msg_lspid; / pid of last msgsnd call / ushort msg_lrpid; / pid of last msgrcv call / time_t msg_stime; / last msgsnd time / time_t msg_rtime; / last msgrcv time / time_t msg_ctime; / last change time */
ipc_perm structure that specifies the access permissions on the message queue.
Number of messages currently on the message queue.
Maximum number of bytes of message text allowed on the message queue.
ID of the process that performed the last msgsnd system call.
ID of the process that performed the last msgrcv system call.
Time of the last msgsnd system call.
Time of the last msgcv system call.
Time of the last system call that changed a member of the msqid_ds structure.
A semaphore set is uniquely identified by a positive integer (its semid) and has an associated data structure of type struct semid_ds, defined in , containing the following members:
ipc_perm structure that specifies the access permissions on the semaphore set.
Time of last semop system call.
Time of last semctl system call that changed a member of the above structure or of one semaphore belonging to the set.
Number of semaphores in the set. Each semaphore of the set is referenced by a non-negative integer ranging from 0 to sem_nsems-1.
A semaphore is a data structure of type struct sem containing the following members:
Semaphore value: a non-negative integer.
ID of the last process that performed a semaphore operation on this semaphore.
Number of processes suspended awaiting for semval to increase.
Number of processes suspended awaiting for semval to become zero.
Shared Memory Segments
A shared memory segment is uniquely identified by a positive integer (its shmid) and has an associated data structure of type struct shmid_ds, defined in , containing the following members:
struct ipc_perm shm_perm; int shm_segsz; /* size of segment / ushort shm_cpid; / pid of creator / ushort shm_lpid; / pid, last operation / short shm_nattch; / no. of current attaches / time_t shm_atime; / time of last attach / time_t shm_dtime; / time of last detach / time_t shm_ctime; / time of last change */
ipc_perm structure that specifies the access permissions on the shared memory segment.
Size in bytes of the shared memory segment.
ID of the process that created the shared memory segment.
ID of the last process that executed a shmat or shmdt system call.
Number of current alive attaches for this shared memory segment.
Time of the last shmat system call.
Time of the last shmdt system call.