IPC is an operating system facility that allows processes within a system or from different system to communicate (exchange information and synchronise) with each other. It is important since it allows information sharing between processes, Parallelism#, modularity, and convenience.
There are several methods of IPC:
- Pipe#
- Named Pipe (FIFO)#
- Message Queue#
- Semaphore in System V#
- Shared Memory
For the latter three methods (message queues, semaphore and shared memory), the kernel will create an object called IPC object which stores its information. The following codes show an example for an IPC object named as ipc_perm
:
struct ipc_perm {
uid_t uid; // owner's user id
gid_t gid; // owner's group id
uid_t cuid; // creater's user id
gid_t cgid; // creater's group id
mode_t mode; // permissions
ulong_t seq; // slot usage sequence number
key_t key; // IPC key associated with the object
};
Note: See IPC Facilities Key#.
These IPC objects could be checked with the command ipcs {flags}
(abbreviated from IPC show) comes with the flags -m
(shared memory), -s
(semaphore) and -q
(message queue), and be removed by ipcrm {obj} {id}
(abbreviated from IPC remove) with msg
(message queue), sem
(semaphore) and shm
(shared memory).