Site icon DataFlair

Interprocess Communication in Operating System

OS Inter-process communicationOS Inter-process communication

FREE Online Courses: Elevate Your Skills, Zero Cost Attached - Enroll Now!

Inter-process communication helps exchange data between multiple threads in one (or more) process or program. It doesn’t matter whether the process is running on single or multiple computers (connected by a network). It allows coordination of activities among various program processes running concurrently in an OS.

This is a set of programming interfaces that allow a program to handle multiple user requests at the same time. As every user request results in multiple processes running in the OS, it is necessary for processes to communicate with each other. There are two types of communications:

Synchronization in Interprocess Communication

Synchronization is an important part of IPC that is either handled by the communicating processes or provided by an interprocess control mechanism. Following are some methods that help provide synchronization:

Approaches in Inter-Process Communication

Following are some important methods for interprocess communication:

Pipes: This half-duplex method allows communication between two related processes. A half-duplex method allows the first process to communicate with the second process. In order to achieve a full-duplex, we need to add another pipe.

Message Passing: It helps a process communicate and synchronize with each other without resorting to shared variables. IPC provides two operations on message passing, namely, sending a message of either fixed or variable size and receiving a message.

Message Queues: A linked list that stores messages in the kernel and is identified by a message queue identifier. It provides communication between one or many processes with full-duplex capacity.

Direct Communication: This requires processes to name each other explicitly. A single link is then established between a pair of communicating processes.

Indirect Communication: This is established when processes share a common mailbox. Each pair of processes can share multiple communication links. Similarly, one link can communicate with several processes and it can either be bi-directional or unidirectional.

Shared Memory: This is the shared memory between two or more processes, established using shared memory between all the processes. It requires protection from each process that can be achieved through synchronized access among processes.

FIFO: A full-duplex method where the first process can communicate with the second process, and vise-versa. This is communication between two unrelated processes.

Need of IPC

Following are the reasons we need IPC

Terms Used in IPC

Following are some terms in IPC:

Like FIFO vs Unlike FIFO

LIKE FIFO UNLIKE FIFO
Follows FIFO method Pulls particular urgent messages before they reach the front
Is independent of sending and receiving processes Ever-ready, there is no need to open or close it
Data transfer among unrelated processes No synchronization problems between open & close

Summary

IPC helps exchange data between multiple threads in one (or more) process or program. It is a set of programming interfaces that allow a program to handle multiple user requests at the same time. Following are the approaches of IPC:

Exit mobile version