Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 9

Operating System – Inter Process

Communication

Lecture 6

1
Inter process communication

Process within a system may be independent or cooperating.

•It is a mechanism whereby one process can communicate or


exchange data, with another process. or
•Set of techniques for the exchange of data among multiple
threads in one or more process.
•Process may be running on one or more computers
connected by a network.

2
Why IPC

• Information Sharing
• Resource Sharing
• Computation Speedup
• Synchronization
• Modularity
• Convenience

3
IPC Mechanism

Following are IPC mechanisms.


•Pipes − Communication between two related processes. The mechanism is half
duplex meaning the first process communicates with the second process. To
achieve a full duplex i.e., for the second process to communicate with the first
process another pipe is required.
•FIFO − Communication between two unrelated processes. FIFO is a full duplex,
meaning the first process can communicate with the second process and vice
versa at the same time.
•Message Queues − Message queue provides an asynchronous communication
protocol, meaning that the sender and receiver of the message do not need to
interact with the message queue at the same time. Messages placed onto the
queue are stored until the recipient retrieved them. Communication between two
or more processes with full duplex capacity. The processes will communicate with
each other by posting a message and retrieving it out of the queue. Once
retrieved, the message is no longer available in the queue.

4
• Shared Memory − Communication between two or more processes is
achieved through a shared piece of memory among all processes. The
shared memory needs to be protected from each other by
synchronizing access to all the processes.
• Semaphores − Semaphores are meant for synchronizing access to
multiple processes. When one process wants to access the memory
(for reading or writing), it needs to be locked (or protected) and
released when the access is removed. This needs to be repeated by
all the processes to secure data.
• Signals − Signal is a mechanism to communication between multiple
processes by way of signaling. This means a source process will send
a signal (recognized by number) and the destination process will
handle it accordingly.

5
• File − A computer file is a block of arbitrary information, or resource
for storing information. A file is durable in the sense that it remains
available for programs to use after the current program has finished.
• Socket – Sockets provide point-to-point, two-way communication
between two processes. Sockets are very versatile and are a basic
component of IPC. A socket is an endpoint of communication to which
a name can be bound. It has a type and one or more associated
processes. Socket exist in communication domains. A socket domain
is an abstraction that provides an addressing structure and a set of
protocols. Socket connect only with sockets in the same domain.

6
Message Passing Systems

• Direct or Indirect communication


• Symmetric or Asymmetric communications
• Automatic or Explicit buffering

7
Synchronizing Messages

Message passing may be either blocking or non blocking.


•Blocking send: Sender blocked until message received by mail box or
process.
•Non blocking send: Sender resumes operation immediately after
sending
•Blocking receive: receiver blocks until a message is available
•Non blocking receive: receiver returns immediately with either a valid
or null message.

8
Buffering

All messaging system require framework to temporarily buffer messages.


These queues are implemented in one of three ways:
•Zero capacity: No message may be queued within the link, required
sender to block until receivers retrieves message.
•Bounded capacity: link has finite number of message buffers. F no
buffers are available then sender must block until one is freed up.
•Unbounded capacity: Link has unlimited buffer space, consequently
send never needs to block.

You might also like