The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 Interprocess Communication

The following message passing, semaphore and shared memory services form an Interprocess Communication facility. Certain aspects of their operation are common, and are described below.

IPC Functions
msgctl() msgget() msgrcv()
msgsnd() semctl() semget()
semop() shmat() shmctl()
shmdt() shmget()  

Another Interprocess Communication facility is provided by functions in the Realtime Feature Group.

 IPC General Description

Each individual shared memory segment, message queue and semaphore set is identified by a unique positive integer, called respectively a shared memory identifier, shmid, a semaphore identifier, semid, and a message queue identifier, msqid. The identifiers are returned by calls on shmget(), semget() and msgget(), respectively.

Associated with each identifier is a data structure which contains data related to the operations which may be or may have been performed. See <sys/shm.h>, <sys/sem.h> and <sys/msg.h> for their descriptions.

Each of the data structures contains both ownership information and an ipc_perm structure, see <sys/ipc.h>, which are used in conjunction to determine whether or not read/write (read/alter for semaphores) permissions should be granted to processes using the IPC facilities. The mode member of the ipc_perm structure acts as a bit field which determines the permissions.

The values of the bits are given below in octal notation.

Bit Meaning
0400 Read by user
0200 Write by user
0040 Read by group
0020 Write by group
0004 Read by others
0002 Write by others

The name of the ipc_perm structure is shm_perm, sem_perm or msg_perm, depending on which service is being used. In each case, read and write/alter permissions are granted to a process if one or more of the following are true (xxx is replaced by shm, sem or msg, as appropriate):

Otherwise, the permission is denied.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]