Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
What is message passing technique in OS?
Message Passing is an inter-process communication (IPC) mechanism that allows processes to communicate and synchronize their actions without sharing the same address space. Unlike shared memory, processes exchange data by sending and receiving messages through the operating system kernel.
For example − chat applications, email systems, and distributed computing applications use message passing to enable communication between processes running on different machines.
How Message Passing Works
Message passing involves two primary operations −
send(message) − Sends a message to a destination process
receive(message) − Receives a message from a source process
Types of Messages
Messages can be classified based on their size −
| Message Type | Implementation | Programming Complexity |
|---|---|---|
| Fixed Size | Simple system implementation | More complex programming |
| Variable Size | Complex system implementation | Simpler programming |
Communication Link Establishment
For two processes P1 and P2 to communicate, a communication link must be established between them. This link can be implemented through various methods −
Direct Communication − Processes explicitly name each other
Indirect Communication − Messages are sent through mailboxes or ports
Synchronous Communication − Sender blocks until message is received
Asynchronous Communication − Sender continues execution after sending
Characteristics
The key characteristics of message passing include −
No Shared Memory − Processes do not share address space, eliminating memory conflicts
Network Communication − Suitable for distributed systems where processes run on remote machines
Kernel Involvement − Communication occurs through system calls, making it slower than shared memory
Data Safety − Ideal for sharing small amounts of data without synchronization issues
Automatic Synchronization − The OS handles synchronization between communicating processes
Advantages and Disadvantages
| Advantages | Disadvantages |
|---|---|
| No memory conflicts | Slower than shared memory |
| Works across networks | Higher system overhead |
| Built-in synchronization | Limited by message size |
| Process isolation maintained | Requires kernel intervention |
Conclusion
Message passing is a fundamental IPC mechanism that enables safe communication between processes without shared memory. While slower than shared memory approaches, it provides excellent isolation and is essential for distributed systems and network-based applications.
