Table of contents
1.
Introduction
2.
What is Inter-process Communication in OS?
3.
Synchronization in Inter Processor Communication
3.1.
Mutual Exclusion
3.2.
Semaphore
3.2.1.
Binary Semaphore
3.2.2.
Counting Semaphore
3.3.
Barrier
3.4.
Spinlock
4.
Approaches of Interprocess Communication
4.1.
Pipe
4.2.
Shared Memory
4.3.
Message Queue
4.4.
Message Passing
4.5.
Direct Communication
4.6.
Indirect Communication
4.7.
FIFO
4.8.
Some other different processes
4.8.1.
Socket
4.8.2.
File
4.8.3.
Signal
5.
Why Inter-Process Communication (IPC) is Required?
6.
Frequently Asked Questions
6.1.
Why is synchronization necessary in interprocessor communication?
6.2.
What are some of the most effective approaches to interprocessor communication?
6.3.
Which is the fastest IPC mechanism?
6.4.
What is Semaphore, and what are its types?
7.
Conclusion
Last Updated: Jul 11, 2024
Easy

Inter -Process Communication in OS

Author Muskan Gupta
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

In general, Interprocess Communication is a mechanism provided by the Operating System (or OS). The various processors in a multiprocessor system should be provided with a facility for communicating with each other. The working of this mechanism is to provide communications between several processes.

In short, intercommunication allows a process to let another process know that some event has occurred or data is to be transferred from one process to another.

Inter-Process Communication

This article will help you understand Interprocessor Communication and Synchronization, methods to provide synchronization, approaches used for inter-process communication, and the importance of Inter-process communication.

Recommended Topic, Microinstruction in Computer Architecture

What is Inter-process Communication in OS?

Interprocessor communication is used for interchanging useful information among various regions in one or more processes (or programs). This communication could involve letting another process know that some event has occurred or the transferring of data from one process to another.

                 

Interprocess communication illustration

Source: https://geekylane.com

Synchronization in Inter Processor Communication

Synchronization is an essential part of interprocess communication. It refers to a case where the data used to communicate between processors is control information. It is either given by the interprocess control mechanism or handled by the communicating processes.

It is required to maintain the correct sequence of processes and to make sure equal access to shared writable data. 

Multiprocessor systems have various mechanisms for the synchronization of resources. Below are some methods to provide synchronization are as follows −

  1. Mutual Exclusion
  2. Semaphore
  3. Barrier
  4. Spinlock

Mutual Exclusion

Mutual Exclusion requires that only a single process thread can enter the critical section one at a time. This also helps synchronize and prevents the race condition by creating a stable state.

Semaphore

Semaphore is a type of variable that generally controls the access to the shared resources by several processes. Further, Semaphore is divided into two types as follows:

Binary Semaphore

A binary semaphore is limited to zero or one. It could be used to control access to one resource. In particular, it can be used to force the same release of an important category in the user code.

Counting Semaphore

Counting semaphore may take any integer value. It could be used to control access to resources having many instances.

Barrier

A barrier ( as evident by its name) does not allow an individual process to proceed unless all the processes do not reach it. Many parallel languages use it, and collective routines impose barriers.

Spinlock

As evident by its name, a spinlock is a type of lock that prevents processes from operating any function unless it is available. The processes which are trying to acquire the spinlock wait in a loop while checking if the lock is available or not. This is also known as busy waiting because the process is not doing any helpful operation even though it is active.

Also See, Shift Registers in Digital Electronics

Approaches of Interprocess Communication

Following are the approaches to implement Inter-process Communication:-

  1. Pipes
  2. Shared Memory
  3. Message Queue
  4. Direct Communication
  5. Indirect Communication
  6. Message Passing
  7. FIFO

 

Approaches to interprocess communication

Source-https://www.guru99.com 

 

For understanding the provided approaches in a better way, let us discuss them individually:-

Pipe

Pipe is a unidirectional data channel in which data can be moved in only one direction at a time. For standard input and output methods, we can use two such pipes to create two-way channels to send and receive the data in two processes, i.e, in input and output. These are used in all POSIX(Portable Operating System Interface) systems and various versions of Windows OS.

                              

 

Pipe

Source: https://tuxthink.blogspot.com/

Shared Memory

Shared memory is a type of memory that can be used or accessed by multiple processes simultaneously. This is done for a reason as processes can communicate with each other. That is why almost all POSIX systems and Windows operating systems use shared memory.

                                                                           

Shared memory

Source: https://binaryterms.com/

Message Queue

Multiple processes can read-write the data to the message queue even without connecting. Messages are stored in the queue till their recipient retrieves them back. Message queues are helpful for interprocess communication and are also used by most operating systems.

Message queue

Source: https://neilkillen.com/

Message Passing

It is a mechanism that processes synchronization and communicates with each other. But, using this mechanism, the processes can communicate without the shared variables being restored.

Generally, the inter-process communication mechanism provides two operations that are as follows:

  • send (message)
  • received (message)

A diagram that illustrates message passing of interprocessor communication is as follows:

                                                                                

Message passing system

Source: https://binaryterms.com/

Direct Communication

Generally, a link is established between two communication processes in this type of communication. However, only one link can exist in every pair of communicating processes.

Indirect Communication

When processes share a common mailbox then only indirect communication can be established. Here, each pair of these processes shares multiple links of communication. The nature of these shared links could be unidirectional or bi-directional.

FIFO

It is general communication between two unrelated processes. It is also considered full-duplex, which means that one process can communicate with another and vice versa.

Some other different processes

The various other processes are as follows:-

Socket

It is an endpoint for receiving or sending the data in a network. It is suitable for the data sent between processes on the same computer or different computers on the same network. That is why several types of operating systems use it.

File

A file is a data record or a document stored on the disk. It can be acquired on demand by the file server. As per requirement, the data can be accessed.

Signal

As its name shows, they are a signal used in inter-process communication minimally. Typically, they are the messages of systems that are sent by one process to another. Therefore, they are not used for transmitting data but in remote commands among multiple processes.

Why Inter-Process Communication (IPC) is Required?

There are various reasons to use inter-process communication for sharing the data. Here are some of the most important reasons that show the importance of inter-process communication:

  • It helps in speeding up modularity
  • It is computational.
  • It gives the privilege of separation as well as connection.
  • Convenience
  • It allows the operating system to communicate and synchronize its actions. 

    Recommended Topic - Memory hierarchy in computer network

Frequently Asked Questions

Why is synchronization necessary in interprocessor communication?

To support Communication and Coordination between multiple processors so that errors do not occur.

What are some of the most effective approaches to interprocessor communication?

Pipes, Shared memory, Message Queue, and Passing are practical approaches to interprocess communication.

Which is the fastest IPC mechanism?

The fastest Inter-Process Communication (IPC) mechanism is typically shared memory because it allows multiple processes to access the same memory space without needing to copy data between processes, resulting in high-speed data exchange.

What is Semaphore, and what are its types?

Semaphore is a variable that controls access to shared resources by several processes. Binary and Counting Semaphores are its two types.

Conclusion

In this article, we have extensively discussed the concepts of Interprocessor Communication and Synchronization, such as methods to provide synchronization, approaches used for interprocess communication, the importance of Inter-process communication, and some frequently asked questions. 

Recommended Readings:

Check out this problem - Queue Implementation

We hope that this blog has helped you enhance your knowledge regarding Interprocessor Communication and Synchronization and if you would like to learn more, check out our articles on interprocessor-arbitration. Do upvote our blog to help other ninjas grow. Happy Coding!

Live masterclass