TASK COMMUNICATION
TASK COMMUNICATION
TASK COMMUNICATION:
In a multitasking system, multiple tasks/processes run concurrently (in pseudo parallelism) and each
process may or may not interact between. Based on the degree of interaction, the processes running on
an OS are classified as
Co-operating Processes: In the co-operating interaction model one process requires the inputs from
other processes to complete its execution.
Competing Processes: The competing processes do not share anything among themselves but they
share the system resources. The competing processes compete for the system resources such as file,
display device, etc. Co-operating processes exchanges information and communicate through the
following methods.
Co-operation through Sharing: The co-operating process exchange data through some shared
resources.
Co-operation through Communication: No data is shared between the processes. But they
communicate for synchronisation. The mechanism through which processes/tasks communicate each
other is known as Inter Process/Task Communication (IPC). Inter Process Communication is essential
for process co-ordination.
The various types of Inter Process Communication (IPC) mechanisms adopted by process are
kernel (Operating System) dependent. Some of the important IPC mechanisms adopted by
various kernels are explained below.
1. Shared Memory:
A. Pipes:
Pipes are a type of shared memory used for inter-process communication (IPC).
They follow the client-server architecture, where the process creating the pipe is the pipe
server, and the process connecting to the pipe is the pipe client.
Pipes act as conduits for information flow and have two conceptual ends.
The unidirectional pipe can be visualised as
There are two types of pipes for Inter Process Communication in Microsoft Windows
Desktop Operating Systems:
a. Anonymous Pipes: Anonymous pipes are unnamed and unidirectional pipes used for data
transfer between two processes. They are limited to one-way communication.
b. Named Pipes: Named pipes are named, unidirectional, or bidirectional pipes used for data
exchange between processes. Named pipes allow point-to-point communication and can be
used between processes on the same machine or different machines connected to a network.
B. Memory-Mapped Objects:
Advantages of Pipes:
Disadvantages of Pipes:
2. Message Passing:
Suppose, process 1 and process 2 communicated together by establishing the communication link as
shown in the figure above. After that, they exchange the message through send and receive
operations. The message is transferred in the First In First Out (FIFO) style. The standard message
exchanged by the processes contains 2 parts. Such as
Header: It contains the type of message, source and destination identities, length of the message, and
control information like priority, sequence number, and low disk space actions.
Message Queue:
A message queue is a form of inter-process communication (IPC) that allows processes to
exchange messages through a shared queue.
Processes can send messages to the queue, and other processes can retrieve and process those
messages.
Message queues typically provide features such as FIFO (First-In-First-Out) ordering,
priority-based message handling, and buffering.
They are commonly used in multi-threaded or multi-process systems where communication
needs to be asynchronous and decoupled.
Mailbox:
A mailbox is another form of message passing IPC where processes can exchange messages
through a designated mailbox.
Each process has its own mailbox, which acts as a storage location for incoming and outgoing
messages.
Processes can send messages to other processes' mailboxes, and the recipient process can
retrieve and process those messages from its mailbox.
Mailboxes are typically implemented as a data structure in memory or as part of an operating
system's IPC facilities.
Advantages of Mailboxes:
Signaling:
Signaling is a method of communication where one process notifies another process about an
event or condition.
It involves the use of signals or flags to indicate a specific state or event to other processes.
Signaling can be implemented through various mechanisms such as signals, interrupts, shared
variables, or semaphores.
Advantages of Signaling:
4. Sockets:
Sockets are a programming interface that enables communication between processes over a
network.
They provide a reliable, bidirectional, and stream-oriented communication channel between
two endpoints (client and server).
Sockets can be used for various network protocols, such as TCP (Transmission Control
Protocol) or UDP (User Datagram Protocol).
TCP sockets provide reliable, ordered, and error-checked communication, while UDP sockets
offer a connectionless and lightweight communication mechanism.
Sockets are widely used in client-server architectures, web applications, and network
programming.
They allow processes running on different machines to communicate and exchange data.
In summary, task communication can be achieved through various methods such as shared memory,
message passing, remote procedure call (RPC), and sockets. Each method has its own advantages and
use cases, and the choice of communication mechanism depends on factors such as performance
requirements, data sharing needs, and network architecture.
Miscellaneous:
1. Shared Memory:
Advantages:
i. Fast and efficient communication as processes can directly access shared data.
ii. Low overhead as there is no need for message passing or copying data.
iii. Suitable for scenarios requiring high-performance data sharing, such as parallel computing.
Disadvantages:
2. Message Passing:
Advantages:
i. Provides a higher level of abstraction, making it easier to reason about and control the flow of
communication.
ii. Supports both synchronous and asynchronous communication mechanisms.
iii. Suitable for distributed systems and parallel computing environments.
iv. Can be used for communication between processes running on the same machine or different
machines connected over a network.
Disadvantages:
i. Requires message passing primitives and overhead for sending and receiving messages.
ii. Message passing may incur additional latency compared to shared memory.
iii. Complex message structures and serialization/deserialization may be needed for passing non-
trivial data.
Advantages:
Disadvantages:
i. Requires network connectivity and may be affected by network latency and reliability.
ii. Introduces additional overhead due to serialization, network communication, and
marshaling/unmarshaling of data.
iii. May have limitations on data types and parameter passing compared to local function calls.
4. Sockets:
Advantages:
Disadvantages:
i. Requires network connectivity and may be affected by network latency and reliability.
ii. Introduces overhead for establishing and maintaining network connections.
iii. Requires explicit handling of data packaging, sending, and receiving at the application level.
S.
Synchronous Inter-Process Asynchronous Inter-Process
N
Communication communication
o
It is also known as blocking inter- It is also known as non-blocking inter-process
1 process communication in both communication in both send and receive
send and receive modes. modes.
Blocking send mode: The sending Non-block send mode: The message will be
process is blocked until the sent by the sending process and resumes the
2
message is received by the operation. It doesn’t matter whether the
receiving process. receiver exists or not.
Blocking receive mode: In this, the Non-blocking receive mode: The receiver
receiver can block the available doesn’t wait for the sender to send the
3 message and will not continue the message or data and continues the process. It
process until the sending process receives either a NULL message or a valid
exists. transmitted message by the sender.
In this communication, a process that receives
This communication occurs
asynchronous messages may or may not be
4 between various processes running
used by the process it is trying to send a
at the same time.
message to.
It helps to share the same data or information between the multiple processes and perform various
tasks. In this, the process requires access to the remote process.
The different processes can share the resources to provide communication between them.
It increases the computational speed during communication between the processes.
It enhances efficiency because the construction is divided into various modules. Where these
modules cooperate using IPS.
Privilege separation.
Comfort.
It helps the processes and OS to communicate with each other with synchronization.
The communication is bidirectional.
Allows control of one application with another application.
Enables data sharing without any interference.
Q3. The disadvantages of inter-process communication are,
There are 4 operations performed in IPC to exchange the data between the processes.
Send
Receive
Connect
Disconnect