Interprocess Communication (IPC)
Interprocess Communication (IPC)
(IPC)
Introduction to IPC
• In order for the cooperating processes to
exchange data and information.
• Two fundamental models – shared memory
and message passing.
• In the former, processes exchange
information by reading and writing data to the
shared region.
• In the latter, messages exchanged between
the cooperating processes.
Communication models : message passing (left)
and shared memory (right).
Shared-Memory Systems
• A region of shared memory needs to be
established by communicating processes.
• Producer-consumer problem.
• A compiler may produce assembly code, which
is consumed by an assembler.
• Buffer of items that is filled by the producer
and emptied by the consumer.
• Will reside in a region of memory shared by
the cooperating processes.
Message-Passing Systems
• Does the function of allowing the processes to
communicate with each other without the
need to use shared variables.
• Particularly useful in a distributed
environment where the communicating
processes may reside on different computers
connected by a network.
• Provision of at least two operations –
send(message) and receive(message).
• Communication link.
Methods for logically implementing a link
and send()/receive() operations
• Direct or indirect communication
• Synchronous or asynchronous communication
• Automatic or explicit buffering
Naming
• Direct communication – each process that
wants to communicate must explicitly name
the recipient or sender of the communication.
send(P, message)—Send a message to process P.
receive (Q, message)—Receive a message from
process Q.
• Communication link properties –
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.
A link is associated with exactly two processes.
Between each pair of processes, there exists exactly
one link.
• Symmetry in addressing.
• Asymmetry in addressing - only the sender
names the recipient, the recipient is not required
to name the sender.
send(P, message) - Send a message to process P.
receive(id, message) - Receive a message from any
process; the variable id is set to the name of the
process with which communication has taken place.
• Disadvantage – limited modularity.
• Indirect communication – messages are sent
to and received from mailboxes or ports.
• A mailbox can be viewed abstractly as an
object into which messages can be placed by
processes and from which messages can be
removed.
• Each mailbox has a unique identification.
• A process can communicate with some other
process via a number of different mailboxes.
• Two processes can communicate only if the
processes have a shared mailbox.
send(A, message)—Send a message to mailbox A.
receive(A, message)—Receive a message from
mailbox A.
• Communication link properties –
A link is established between a pair of processes
only if both members of the pair have a shared
mailbox.
A link may be associated with more than two
processes.
Between each pair of communicating processes,
there may be a number of different links, with
each link corresponding to one mailbox.
• Mailbox may be owned by a process or operating
system.
Synchronization
• Message passing may be either blocking or
nonblocking - also known as synchronous and
asynchronous.
Blocking send : The sending process is blocked until
the message is received by the receiving process or by
the mailbox.
Nonblocking send : The sending process sends the
message and resumes operation.
Blocking receive : The receiver blocks until a message
is available.
Nonblocking receive : The receiver retrieves either a
valid message or a null.
• When both send() and receive() are blocking,
we have a rendezvous between the sender
and the receiver.
Buffering
• messages exchanged by communicating
processes reside in a temporary queue.
• Zero capacity (message system with no
buffering).
• Bounded capacity.
• Unbounded capacity.