Process Communication Mechanism

Filter Course


Process Communication Mechanism

Published by: Zaya

Published date: 22 Jun 2021

Process Communication Mechanism Photo

Process Communication Mechanism

Working together with multiple processes requires an inter-process communication (IPC) method which will allow them to exchange data along with various information. There are two primary models of inter-process communication:
i. shared memory and
ii. message passing

In the shared-memory model, a region of memory that is shared by cooperating processes gets established. Processes can be then able to exchange information by reading and writing all the data to the shared region. In the message-passing form, communication takes place by way of messages exchanged among the cooperating processes.

An advantage of the shared memory model is that memory communication is faster as compared to the message-passing model on the same machine. However, the shared memory model may create problems such as synchronization and memory protection that need to be addressed.

The two communications models are contrasted in the figure below:

process communication mechanism

Message passing is the mechanism for processes to communicate and to synchronize their actions without resorting to a shared variable.
This method of Inter-Process Communication (IPC) uses two primitives:

  • send (destination, message);
  • receive (source, message);

-Send calls sends a message to a given destination.
-Receiver receives a message from a given source. If no message is available, the receiver can block until one arrives, or it can return immediately with an error code.

If processes P and Q need to communicate, they need to
1. establish a communication link (physical or logical) between them
2. exchange message via send/receive

Processes must name each other explicitly:
1. send(P, message): send a message to process P
2. receive(Q, message): receive a message from process Q

An advantage of the message passing model is that it is easier to build parallel hardware. This is because message-passing model is quite tolerant of higher communication latencies. It is also much easier to implement than the shared memory model.

However, the message passing model has slower communication than the shared memory model because the connection setup takes time.