Coupon Accepted Successfully!


Interprocess Communication

Processes executing concurrently in the operating system may be either independent process or cooperating process. A process is called cooperating if is affected by the other processes executing in the system, whereas it is called Independent when it’s execution is not dependant on execution of other processes. Cooperating processes require Interprocess communication (IPC) mechanisms that enables them to send and receive data. Since processes frequently need to communicate with other processes therefore, there is a need for a well-structured communication, without using interrupts, among processes. As given earlier, there are two models of IPC which will now be described in detail.
1. Message Passing Model(a)
2. Shared Memory Model(b)

Message Passing Model

Message passing provides a mechanism to allow processes to communicate and to synchronize their actions without sharing the same address space and is particularly useful in a distributed environment, where the communicating processes may reside on different computers connected by a network.
For message passing facility, we need at least two operations:
1. Send (Message) - Fixed width or variable
2. Receive(Message)
If processes want to communicate, say for example A and B wish to communicate, a communication link must first be established. The communication link can be logically described as:
1. Direct or Indirect Communication
Under Direct communication, Process A should explicitly name the recipient of the message i.e. Process B. In this the send( ) and receive( ) are defined as:
  • SEND ( A , MESSAGE ) – Sends a message to process A.
  • RECEIVE( B, MESSAGE) – Receive a message from process B.
Three characteristics of Direct communication:
a) A link is automatically established between every pair of processes that want to communicate. The process only need to know about other process identity.
b) A link is established with exactly two of the processes.
c) Between each pair of process, there exists only a single link.
Under Indirect communication, messages are sent and received via mailboxes also known as ports. Mailboxes can be simply understood as an object in which messages are temporarily stored by first process and removed by the other process In Indirect communication, the send( ) and receive( ) are defined as:
  • SEND (X, MESSAGE ) – Send/store message to mailbox X
  • RECEIVE(X, MESSAGE) – Receive/remove message from mailbox X
Three characteristics of Indirect communication:
a) A link is established between every pair of processes only if both processes share a common mailbox.
b) A link can be established between two or more processes.
c) Between each pair of process, there may exists more than a single link.

Synchronous or Asynchronous Communication

Communication between processes takes places through calls to send( ) and receive( ) calls. There are different design options for implementing each function. Message passing may be either synchronous and asynchronous or blocking and nonblocking.
Blocking Send – sending is blocking until the mesg. Is received by receiving process
Non Blocking Send – sending process sends message and resumes operation
Blocking Receive – receiver blocks until a message is available
NonBlocking Receive – receiver retrieves either a valid message or a NULL.

Automatic or Explicit Buffering

Whether communication is direct or indirect, messages exchanged by communicating processes reside in a temporary queue. Depending on how the queue is implemented, the method of execution of message-passing model varies:
1. Zero Capacity – Queue has max. length of zero, hence link can’t have any messages waiting in it. So sender must wait until recipient retrieves the message.
2. Bounded Capacity – Finite size queue. Till queue is not full, sender can send messages. Receiver can retreieve messages until queue is empty.
3. Unbounded Capacity – Queue length is assumed to be infinite. Thus any number of messages can wait in it.

Shared Memory Model

IPC using shared memory required the communicating processes to have a common region of shared memory. Often, shared-memory region resides in the address space of process creating the shared memory segment. Other process(es) that want to communicate to this process must attach themselves to this shared memory region. This is done in UNIX by shmat( ) system call, which stands for shared memory attach. Thus 2 processes can exchange information by reading and writing data in the shared areas.

Client – Server Communication

In section above, we explained how communication was done between 2 processes via shared memory or message passing model. This can be used for client – server communications as well, but we have special techniques available that is specially suited for client – server communication viz Sockets and Remote procedure calls.


  • A socket is defined as an endpoint for communication
  • It is a concatenation of IP address and port
  • The socket refers to port 808 on host
  • Communication takes place between a pair of sockets
When a client process initiates a request for communication, it is assigned a port by the host computer. This port is a random number and is greater than 1024. The scenario can be something as shown in diagram above. The packers travelling between the hosts are delivered to the appropriate process based on the destination port number. All connection must be unique. Therefore, if another process also on host X wishes to establish another communication with the same web server, it would be assigned a port number greater than 1024, but not equal to 1625. This thus ensures all connections consist of a unique pair of sockets.

Remote Procedure Calls

Remote procedure calls (RPC) is a powerful technique for constructing client-server based applications. It is based on extending the notion of conventional, or local procedure calling, so that the called procedure need not exist in the same address space as the calling procedure.
The two processes may be on the same system, or they may be on different systems with a network connecting them. By using RPC, programmers of distributed applications avoid the details of the interface with the network. The transport independence of RPC isolates the application from the physical and logical elements of the data communications mechanism and allows the application to use a variety of transports.
RPC is similar in many respects to IPC mechanism, and is often built on top of them. But usually RPC is used when the processes are executing on two different systems, client and server. The RPC allows a user to do the communication as if the processes are in same address space, and the complexity of the network, the packing-unpacking of data packets from client-server-client is handled in background by the background stubs.

How RPC Works

An RPC is analogous to a function call. Like a function call, when an RPC is made, the calling arguments are passed to the remote procedure and the caller waits for a response to be returned from the remote procedure. The client makes a procedure call that sends a request to the server and waits. When the request arrives, the server calls a dispatch route in that performs the requested service, and sends the reply to the client. After the RPC call is completed, the client program continues. RPC specifically supportsnetwork applications.

The diagram clearly explains how the remote procedure call works.

Test Your Skills Now!
Take a Quiz now
Reviewer Name