What are the two methods to implement inter process communication?

There are two methods to implement inter process communication they are as follows −

  • Shared memory

  • Message passing

Now, let us understand what a shared memory is.

Shared memory

It is one of the regions for data communication. It is used for communication between single processor and multiprocessor systems where the processes that are to be communicated present on the same machine and they are sharing common address space.

The shared memory code that has to be read or write the data that should be written explicitly by the application programmer.

It is going to provide a maximum speed of computations because the communication is done with the help of shared memory so system calls are used to establish the shared memory.

In shared memory make sure that the processes are not writing to the same location simultaneously.

It follows a faster communication strategy when compared to message passing technique.

Given below is the structure of shared memory −

Message passing

Mainly the message passing is used for communication. It is used in distributed environments where the communicating processes are present on remote machines which are connected with the help of a network.

Here, no code is required because the message passing facility provides a mechanism for communication and synchronization of actions that are performed by the communicating processes.

Message passing is a time consuming process because it is implemented through kernel (system calls). It is useful for sharing small amounts of data so that conflicts need not occur. Here, the communication is slower when compared to shared memory technique.

Given below is the structure of message passing −