Inter-Process Communication

Inter-Process Communication and Synchronization:

Muhammad Abdul Aleem

--

Running processes in Linux:

A running Linux system consists of numerous processes, many of which operate independently of each other. Some processes, however, cooperate to achieve their intended purposes, and these processes need methods of communicating with one another and synchronizing their actions.

How processes communicate to each other:

One way for processes to communicate is by reading and writing information in disk files. However, for many applications, this is too slow and inflexible. Therefore, Linux, like all modern UNIX implementations, provides a rich set of mechanisms for interprocess communication (IPC), including the following:

Signals: which are used to indicate that an event has occurred.
Pipes: (familiar to shell users as the | operator) and FIFOs, which can be used to transfer data between processes.
Sockets: which can be used to transfer data from one process to another, either on the same host computer or on different hosts connected by a network.
File locking: which allows a process to lock regions of a file in order to prevent other processes from reading or updating the file contents.
message queues, which are used to exchange messages (packets of data) between processes.
Semaphores: which are used to synchronize the actions of processes and
shared memory, which allows two or more processes to share a piece of memory.
When one process changes the contents of the shared memory, all of the other
processes can immediately see the changes.

The wide variety of IPC mechanisms on UNIX systems, with sometimes overlapping functionality, is in part due to their evolution under different variants of the UNIX system and the requirements of various standards. For example, FIFOs and UNIX domain sockets essentially perform the same function of allowing unrelated processes on the same system to exchange data. Both exist in modern UNIX systems because FIFOs came from System V, while sockets came from BSD.

--

--

Muhammad Abdul Aleem

A Software Engineer who loves writing and programming || Talks about businesses, Startups, Saas Products.