Professional Documents
Culture Documents
Unit 3 DS
Unit 3 DS
IPC –
Inter-Process Communication (IPC) in distributed systems refers to the mechanism through
which processes running on different computers or within the same computer communicate
and synchronize their actions. IPC allows processes to exchange data, share resources, and
coordinate activities to achieve a common goal.
In the context of distributed systems, IPC is crucial for enabling collaboration and interaction
between distributed components. This communication can occur over a network, enabling
processes to communicate even if they are running on different physical machines.
Characteristics of IPC -
1. Communication Channels:
IPC provides various communication channels for processes to exchange data
and messages, such as shared memory, message passing, sockets, and remote
procedure calls (RPC).
These channels can be uni-directional or bi-directional, synchronous or
asynchronous, depending on the requirements of the application.
2. Abstraction:
IPC abstracts the underlying complexities of communication mechanisms,
providing a standardized interface for processes to interact.
This abstraction allows developers to focus on application logic rather than
low-level communication details.
3. Concurrency and Parallelism:
IPC supports concurrent and parallel execution of processes, allowing multiple
processes to communicate simultaneously.
Processes can execute independently or cooperate with each other to
accomplish tasks efficiently.
4. Synchronization:
IPC mechanisms include synchronization primitives like locks, semaphores,
and barriers to coordinate the execution of concurrent processes.
Synchronization ensures that processes access shared resources in a mutually
exclusive and orderly manner, preventing data corruption and race conditions.
5. Data Transfer:
IPC facilitates the transfer of data between processes, allowing them to share
information and work collaboratively.
Data can be transferred in the form of messages, files, or shared memory
segments, depending on the communication channel used.
6. Error Handling:
IPC mechanisms include error detection and handling capabilities to deal with
communication failures, network errors, or data corruption.
Error handling ensures the reliability of communication between processes
and helps maintain data integrity.
7. Scalability:
IPC supports scalable communication between processes, allowing systems to
handle increasing loads and growing numbers of users.
Scalability is achieved through efficient resource management, optimized
communication protocols, and distributed architectures.
8. Security:
IPC mechanisms include security features to protect communication channels
from unauthorized access, data tampering, and eavesdropping.
Encryption, authentication, and access control mechanisms are employed to
secure IPC in distributed systems, ensuring confidentiality, integrity, and
availability of data.
9. Platform Independence:
IPC mechanisms are often designed to be platform-independent, allowing
processes running on different operating systems or hardware architectures to
communicate seamlessly.
This ensures interoperability across diverse computing environments and
facilitates the development of distributed applications.
Approaches of IPC –
1.Pipes –
Pipes are a simple form of shared memory that allows two processes to communicate
with each other.
It is a half duplex method (or one way communication) used for IPC between two
related processes .
One process writes data to the pipe, and the other process reads data from the pipe.
Pipes can be either named or anonymous, depending on whether they have a unique
name or not.
Named pipes are a type of pipe that has a unique name, and can be accessed by
multiple processes. Named pipes can be used for communication between processes
running on the same host or between processes running on different hosts over a
network.
Anonymous pipes, on the other hand, are pipes that are created for communication
between a parent process and its child process. Anonymous pipes are typically used
for one-way communication between processes, as they do not have a unique name
and can only be accessed by the processes that created them.
2.Shared Memory –
Shared memory allows multiple processes to access the same portion of memory. Each
process can read from and write to the shared memory region.
Provides fast communication as processes directly access shared memory.
Requires synchronization mechanisms (e.g., semaphores, mutexes) to manage access
to shared memory and prevent data corruption.
Well-suited for scenarios where processes need to exchange large amounts of data
frequently.
Can be more efficient than other IPC methods due to its low overhead.
3.Message Passing –
Message passing is a method of Inter Process Communication in OS. It involves the
exchange of messages between processes, where each process sends and receives
messages to coordinate its activities and exchange data with other processes.
Processes can communicate without any shared variables, therefore it can be used in a
distributed environment on a network.
In message passing, each process has a unique identifier, known as a process ID, and
messages are sent from one process to another using this identifier. When a process
sends a message, it specifies the recipient process ID and the contents of the message,
and the operating system is responsible for delivering the message to the recipient
process. The recipient process can then retrieve the contents of the message and
respond, if necessary.
Messages can be sent synchronously or asynchronously.
Synchronous message passing involves blocking until the message is sent or received.
Asynchronous message passing allows processes to continue execution while
messages are being sent or received.
Requires serialization and deserialization of data.
Can be implemented using sockets, pipes, or message queues.
Message passing is used in IPC for a variety of purposes, such as exchanging data
between processes, coordinating the activities of multiple processes, and
implementing complex communication protocols between processes.
4. Message Queue –
Message Queue is a method of Inter Process Communication in OS. It involves the
use of a shared queue, where processes can add messages and retrieve messages for
communication. The queue acts as a buffer for the messages and provides a way for
processes to exchange data and coordinate their activities.
In Message Queue IPC, each message has a priority associated with it, and messages
are retrieved from the queue in order of their priority. This allows processes to
prioritize the delivery of important messages and ensures that critical messages are
not blocked by less important messages in the queue.
Message Queue IPC provides a flexible and scalable method of communication
between processes, as messages can be sent and received asynchronously, allowing
processes to continue executing while they wait for messages to arrive. Additionally,
Message Queue IPC supports the communication between processes running on
different hosts, as the message queue can be implemented as a network service.
5.Direct Communication
Direct communication is a method of Inter Process Communication in OS. It involves
the direct exchange of data between processes, without the use of intermediate
communication mechanisms such as message passing, message queues, or shared
memory.
In direct communication, the sender process must know the identifier of the receiver
process in order to send a message to it.
However, direct communication also has some limitations, as it can lead to tight
coupling between processes, and it can make it more difficult to change the
communication mechanism in the future, as direct communication is hardcoded into
the processes themselves.
6. Indirect Communication
Indirect communication in IPC is a method of communication in which processes do
not explicitly name the sender or receiver of the communication. Instead, processes
communicate through a shared medium such as a message queue or mailbox.
Pairs of communicating processes have shared mailbox.
Link (uni-directional or bi-directional) is established between pairs of processes.
Sender process puts message in the port or mailbox of reciever process and reciever
process takes out (or deletes) the data from mailbox.
The sender and receiver processes do not need to know each other's identifiers in
order to communicate with each other.
The main advantage of indirect communication is that it provides a more flexible and
scalable way for processes to communicate, as processes do not need to have direct
access to each other’s data.
However, indirect communication can also introduce additional overhead, as data
must be copied between address spaces, and the communication mechanism must be
managed by the operating system to ensure that it remains synchronized and
consistent across all processes.