/**/ What is Inter-Process Communication? - Dextutor IPC

What is Inter-Process Communication?

An operating system provides inter-process communication to allow processes to exchange information. Inter-process communication allows programmers to coordinate activities among various processes that are concurrently running in the system.

Processes in the system are of two types:

  • Independent Processes
  • Cooperating Processes

Independent processes are those processes which neither affect nor get affected by other processes running in the system. In other words, Any process that does not share data with other processes is an independent process.

Cooperating processes are those if they can affect or get affected by the other processes running in the system. In other words, a process that shares data with other processes is a cooperating process.

Inter-process communication is useful for creating cooperating processes. For example, ‘ls‘ process and ‘more‘ process can cooperate to produce a paged listing of files and directories.

Why Cooperating processes?

The cooperating processes are important because they provide:

  1. Information sharing among processes
  2. Increase in computational speed
  3. It provides modularity
  4. It provides convenience in accessing data

Methods of IPC

Broadly there are two approaches of implementing inter-process communication

  1. Shared Memory
  2. Message Passing

Shared Memory

Cooperating processes share a region of memory. It is the fastest method for inter-process communication. The operating system creates a common memory segment in the RAM so that several processes can read and write in that memory segment. The processes share the memory region without calling operating system functions.

IPC using Shared memory
Figure-1 Shared Memory

Advantages of Shared Memory

  1. Fastest bidirectional communication method
  2. Can be used with any number of processes
  3. It saves resources

Disadvantages of Shared Memory

  1. Data inconsistency occurs like the Lost update. It needs a concurrency control mechanism
  2. Lack of data protection

Message Passing

It is the second method for inter process communication. It provides two operations for processes to communicate.

  1. Send (message)
  2. Receive (message)

Message passing is slower as compared to shared memory method. This is because it makes use of system calls to provide communication between processes.

IPC using message passing
Figure-2 Message Passing

Methods to implement communication link

To send and receive messages in message passing, a communication link is required between two processes. There are various ways to implement a communication link.

  1. Direct and indirect communication
  2. Synchronous and asynchronous communication
  3. Buffering

Direct and indirect communication

In direct communication, each process must explicitly name the recipient or sender of the communication.

send(P, message) – send a message to process P 
receive(Q, message) – receive a message from process Q

In this method, the link is automatically established. The process must only know the identity of the other process. Link is always created between two processes. One direct link can be used only between one pair of communicating processes. For example, if there two links L1 and L2 then only two processes P1 and P2 can use L1. P3 and P4 can not use L1. Also, two processes can use only a single direct link for communication. For example, P1 and P2 can use only L1 but can not use L2 for communication.

In indirect communication, messages are sent and received through mailboxes or ports.

send(A, message) – send a message to mailbox A 
receive (A, message) – receive a message from mailbox A

Different pair of processes can use the same indirect link for communication. For example, if there is a link L1. Then a pair of processes P1 and P2 and also P3 and P4 can use L1 for communication. Also, two processes can two different indirect links for communication. For example, processes P1 and P2 can use only link L1 as well as link L2 for communication.

Synchronous and asynchronous communication

Message passing may be blocking (synchronous) or non blocking (non-synchronous)

  • Blocking send – blocks the sending process until the receiving process receives the message. This means that the sending process will not send data until the receiving process is also there. For example, in a class, the teacher will not speak until there are students sitting to receive.
  • Non blocking send – the sending process sends the message and resumes operation. Hence, the sending process does not bother whether the receiver is there or not.
  • Blocking receive – the receiver blocks until a message is available. This means that the receiving process will not proceed until the sending process is not there. For example, in a class, the students do not go until the teacher comes and delivers the lecture.
  • Non blocking receive – The receiver process does not wait for the sender to send data. Hence, the receiver retrieves either a valid message or NULL.


The speed of the sender and receiver process can be different. So, it is important to introduce some kind of temporary storage. For example, if your internet connection is slow, the video in youtube gets buffered. The messages exchanged by the communicating process reside in a temporary queue. There are three ways to implement queues.

  • Zero capacity buffer – it means that there is no buffering in the system. If the receiver is slow, then the data will be lost.
  • Bounded buffer – means that the memory used for buffering has a bound to it. Hence, you can not buffer unlimited data.
  • Unbounded buffer – if there is unlimited memory available for buffering.

Difference between shared memory and message passing

Shared MemoryMessage Passing
Processes exchange information by reading or writing into the shared regionThere is direct exchange of messages between processes
It is Useful for exchange of large amount of dataUseful when exchanging small amounts of data
It is Faster than message passing as system calls are required only to establish shared regionIt is Slower than shared memory because it is implemented using system calls

PPT on Inter Process Communication

The above discussion is summarized in the form of a PPT with animations below.
Note: Click within the slide area for animations. Clicking on the “next” slide button will not display any animation

Previous Next
Disk Scheduling Security

Leave a Comment