Skip to content
The Computer Science
TheCScience
  • Engineering Subjects
    • Human Values
    • Computer System Architecture
    • Microprocessor
    • Digital Communication
    • Internet of Things
  • NCERT Solutions
    • Class 12
    • Class 11
  • Solutions
    • HackerRank
      • C Solutions
      • C++ Solutions
      • Java Solutions
      • Python Solutions
      • Algorithms Solutions
      • Data Structures Solutions
    • HackerEarth Solutions
    • Leetcode Solutions
  • JEE 2027
The Computer Science
TheCScience

Message Passing in Operating System | OS Tutorials

YASH PAL, May 25, 2026May 25, 2026

In an operating system, Processes frequently need to communicate with other processes while they are running, and for that, the output of the first process must be passed to the second process and so on. Thus, there is a need for communication between processes, preferably in a well-structured way, not using interrupts. Message passing is the technique used by one process to communicate with another process in an operating system.

Three issues may arise while passing information:

  • First issue – is how one process can pass information to another.
  • Second issue – has to do with making sure two or more processes do not get in each other’s way.
  • Third issue – concern proper sequencing when dependencies are present: if process A produces data and process B prints them. B has to wait until A has produced some data before starting to print.

Table of Contents

  • Message Passing in an Operating System
    • Introduction to Message Passing
    • Design Issues in Message Passing Systems
      • Synchronization
      • Addressing
        • Direct Addressing/Communication
        • Indirect Addressing/Communication
    • Message Format
    • Queuing Discipline
    • Buffering
    • Advantages of Message Passing Schemes

Message Passing in an Operating System

Interprocess Communication (IPC) provides a mechanism to allow processes to communicate and to synchronize their actions without sharing the same address space. Interprocess communication is best provided by a message-passing system. A message system can be defined in several different ways. IPC is particularly useful in a distributed environment where the communication processes (interacting processes) may reside on different computers on a network.

For example, a chat program runs on the World Wide Web.

Note that the shared memory and message-system communication schemes are not mutually exclusive and could be used simultaneously within a single operating system or even a single process.

Introduction to Message Passing

  • When processes interact with one another, two fundamental requirements must be satisfied:
    1. synchronization
    2. Communication
  • Processes need to be synchronized to enforce mutual exclusion; cooperating processes may need to exchange information.
  • Both of these functions are provided by Message Passing. Message passing has the advantage that it lends itself to implementation in distributed and shared memory multiprocessor and uniprocessor systems.
  • The actual function of message passing is normally provided in the form of a pair of primitives: Send (destination, message), Receive (source, message).
  • A Process sends information in the form of a message to another process designated by a destination. A process receives information by executing the receive primitive, indicating the source and the message. It is shown in Figure 1.
Message Passing in Operating System
Figure 1: Message Passing System

Design Issues in Message Passing Systems

Several design issues related to the message-passing system are shown in Figure 2.

Design issue in message passing system
Figure 2: Design issue in the message passing system

Synchronization

  • Some level of synchronization must be provided when a message is communicated between two processes.
  • The receiver cannot receive a message until it has been sent by another process.
  • We need to specify what happens to a process when send or receive primitives are issued.

Send Primitive

  • When a send primitive is executed in a process, there are two possibilities:
  • The sending process is blocked until the message is received or it is not.

Receive Primitive

  • When a process issues a receive primitive, there are also two possibilities:
  • If a message has previously been sent, the message is received, and execution continues.
  • If there are no waiting messages, then either
    1. The process is blocked until a message arrives.
    2. The process continues to execute, abandoning the attempt to receive.
  • Hence, both the sender and receiver can be blocking or non-blocking. We can generate different combinations as-
    1. Blocking send, Blocking receive – Both the sender and receiver are blocked until the message is delivered. It allows tight synchronization among processes.
    2. Nonblocking send, Blocking receiver – The sender may be sending continuously, and the receiver is blocked until the requested message arrives. A process that must receive a message before it can do useful work needs to be blocked until such a message arrives. An example is a server process that exists to provide a service or resource to other processes. It is the most useful combination.
    3. Nonblocking send, Nonblocking Receive – The sending process sends the message and resumes the operation. The receiver retrieves either a valid message or a null. Neither sender nor receiver is required to wait.
  • Nonblocking send is most suitable for natural concurrent programming tasks. The disadvantage of nonblocking send is that an error can lead to a situation in which a process repeatedly generates messages.
  • It also consumes system resources such as buffer space, processor time, etc. Nonblocking send places the burden on the programmer to determine that a message has been received. Blocking receive is suitable for many concurrent programming tasks.

Addressing

If any processes are sending a message, then it is necessary to have a way of specifying in the send primitive which processes are to receive the message. Similarly, receiving processes should indicate the source of a message to be received.

There are two categories of addressing:

  1. Direct Addressing/Communication
  2. Indirect Addressing/Communication
Direct Addressing/Communication
  • Under Direct addressing, each process that wants to communicate must explicitly name the recipient or sender of communication. In this scheme, the send () and receive () primitives are defined as
  • Send (P, message) – Send a message to process P.
  • Receive (Q, message) – Receive a message from process Q.
  • Communication, like in this scheme, has the following properties
    1. A Link is established automatically between every pair of processes that want to communicate. The processes need to know only each other’s identity to communicate.
    2. A Link is associated with exactly two processes.
    3. Between each pair of processes, there exists only one link.
  • This scheme exhibits symmetry in addressing. Symmetry means that both the sender and receiver processes must name the other to communicate.
  • Asymmetry is a variant in this scheme, here only the sender names the recipient, and the recipient is not required to name the sender.
  • Send () and receive () primitives in this scheme are defined as follows.
  • Send (P, message) – send a message to process P.
  • Receive (id, message) – Receive a message from any process.
  • Disadvantages in Symmetric & Asymmetric: Disadvantages of both schemes are the limited modularity of the resulting process definitions.
Indirect Addressing/Communication
  • In this approach, messages are not sent directly from sender to receiver but rather are sent to a shared data structure consisting of queues that can temporarily hold messages. Such queues are generally referred to as mailboxes.
  • Thus, for two processes to communicate, one process sends a message to the appropriate mailbox, and the other process picks up the message from the mailbox. Each mailbox has a unique identification.
  • The send() and receive() primitives are defined as follows:
    • Send (A message) – Send a message to mailbox A.
    • Receive (A message) – Receive a message from mailbox A.
  • In this scheme, the communication link has the following properties:
    1. A link is established between a pair of processes only if both members of the pair have a shared mailbox.
    2. A link may be associated with more than two processes.
    3. Between each pair of communicating processes, there may be some different links, with each link corresponding to one mailbox.
  • The strength of the use of indirect addressing is that by decoupling the sender and receiver, it allows for greater flexibility in the use of messages.

Relationship in Indirect Addressing

In indirect addressing, the relationship between senders and receivers can be of the following types –

Indirect Addressing Relationship in operating system
Figure 3: Relationship in Indirect Addressing

(a) One-to-One Relationship: It allows a private communication link between two processes. Figure 4 shows a one-to-one relationship.

One to One Indirect Addressing Relationship
Figure 4: One-to-One

(b) Many-to-One Relationship: It is useful for client-server interaction; one process provides service to many other processes. In this case, the mailbox is also referred to as a port. Figure 5 depicts the many-to-one relationship.

Many to one relationship
Figure 5: Many-to-one relationship

(c) One-to-Many Relationship: It allows for one sender and multiple receivers; it is useful for applications where a message or some information is to be broadcast to a set of processes. Figure 6 shows the one-to-many relationship.

One to Many Relationship
Figure 6: One-to-Many Relationship

(d) Many-to-Many Relationship: It allows multiple server processes to provide concurrent service to multiple clients. Figure 7 shows the many-to-many relationship.

Many to Many relationship in indirect addressing
Figure 7: Many-to-Many relationship in indirect addressing

Message Format

The format of the message depends on the objectives of the messaging facility and whether the facility runs on a single computer or on a distributed system. Some operating systems preferred short, fixed-length messages to minimize processing and storage overhead. A more flexible approach is to allow variable-length messages. Figure 8 shows a typical message format for an operating system that supports variable-length messages.

The message is divided into two parts:

  1. Header – A header contains information about the message, such as an identification of the source and intended destination of the message, a length field, and a type field, etc.
  2. Body – It contains the actual contents of the message.

Queuing Discipline

  • The simplest queuing discipline is first-in-first-out (FIFO), but this may not be sufficient if some messages are more urgent than others.
  • An alternative is to allow the specifying of message priority, on the basis of message type or by designation by the sender.
  • Another alternative is to allow the receiver to inspect the message queue and select which message to receive next.

Buffering

Whether communication is direct or indirect, the messages exchanged by communication processes reside in a temporary queue. Basically, such queues are implemented in three ways as given below:

  1. Zero Capacity: The queue has a maximum length of zero. Thus, the link cannot have any messages waiting in it. Hence, the sender must block until the recipient receives the message.
  2. Bounded Capacity: The queue has finite length n; thus, at most n messages can reside in the queue. If the queue is not full when a new message is sent, the message is placed in the queue, and the sender can continue execution without waiting. The link’s capacity is finite. If the link is full, the sender must block until space is available in the queue.
  3. Unbounded Capacity: The queue’s length is potentially infinite; any number of messages can wait in it. In this scheme, the sender never blocks.

Note: The zero capacity scheme is sometimes referred to as a message system with no buffering; the other cases are referred to as a system with automatic buffering.

Advantages of Message Passing Schemes

  1. Processes do not need to use shared data for exchanging information.
  2. The kernel can give a warning if the data area mentioned in a receive call is smaller in size than the message to be received.
  3. The kernel takes the responsibility to block the process executing a receive when no message exists for it.
  4. Messages may reside in the buffer until they are received.
  5. The processes may belong to different applications and may even exist in different systems.
engineering subjects Operating System Operating System

Post navigation

Previous post

Leave a Reply

Your email address will not be published. Required fields are marked *

Engineering Core Subjects

Digital Communication Subject
Internet of Things Subject
Computer Architecture subject
Human Value Subject

JEE Study Materials

JEE Physics Notes
JEE Chemistry Notes

TheCScience

At TheCScience.com, our mission is to make quality education accessible to everyone. We provide in-depth, easy-to-understand articles covering Secondary, Senior Secondary, and Graduation-level subjects.

Pages

About US

Contact US

Privacy Policy

DMCA

Our Tools

Hosting - get 20% off

Engineering Subjects

Internet of Things

Human Values

Digital Communication

Computer System Architecture

Microprocessor

Programming Tutorials

Data Structure and Algorithm

C

Java

NCERT

Class 12th

©2026 TheCScience | WordPress Theme by SuperbThemes