Inter-process Communication in OS. Explain its two models

Inter-process communication is a mechanism that allows processes to communicate with each other. The processes of two different computers that connect with the same network can also communicate via Inter-process communication. Communication between the processes should take place in a well-structured manner.

It is used to exchange essential information between threads in single or multiple processes. The main goal of inter-process communication is to facilitate communication between different processes.

Inter-process communication is known as Dynamic data exchange system in windows. In a multiprogramming operating system, multiple processes may be executed simultaneously.

In the context of inter-process communication,

We can classify processes into two categories

  • Independent Process: Independent processes never share their data with other processes, and these processes never ask other processes for data sharing. This process functions independently in the multiprogramming operating system. 
  • Cooperative Process: These processes are just alternatives to independent processes. They share their data with other processes in the system. 

There are two types of models in inter-process communication

1). Shared memory model

The shared memory model creates a region of memory that gets shared between two or more cooperating processes. This model is faster than the message-passing model. Generally, OS prevents the processes from entering the memory of different processes, but we bypass this prevention in this situation. The process itself permits the operating system to eliminate this protection from its memory for the cooperative process. 

Advantage of shared memory: Memory connection is higher on the shared memory model than on the message passing model on a similar device.

Disadvantage of shared memory: It may arise issues like memory security that require to be addressed. Every process that uses the shared memory model requires ensuring that they are not writing to a similar memory address.

2). Message passing model

In the message-passing model, two processes communicate with each other by passing messages. The message-passing model is more useful in the distributed environment when the two devices are connected with the same network, and their process wants to share data. It is quite easy to implement as compared to the shared memory model. It is used to interchange a small amount of data. The message-passing model provides two operations: send a message and receive a message. 

Advantage of message passing model: It is much simpler to implement as compared to the shared memory model.

Disadvantage of message passing model: It has a denser connection than the shared memory model due to the connection setup captures time.