0% found this document useful (0 votes)
14 views20 pages

Advanced Operating Systems for M1IL -Inter Process Communication

The document discusses Inter-Process Communication (IPC), which enables processes to communicate and synchronize actions, distinguishing between independent and cooperating processes. It outlines various IPC mechanisms such as shared memory, semaphores, and message passing, along with their types including unicast and multicast communication. Additionally, it covers practical implementations of IPC in networking, specifically through Remote Procedure Calls (RPC) and sockets, detailing both TCP and UDP communication methods in Java.

Uploaded by

mohamedmechria02
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views20 pages

Advanced Operating Systems for M1IL -Inter Process Communication

The document discusses Inter-Process Communication (IPC), which enables processes to communicate and synchronize actions, distinguishing between independent and cooperating processes. It outlines various IPC mechanisms such as shared memory, semaphores, and message passing, along with their types including unicast and multicast communication. Additionally, it covers practical implementations of IPC in networking, specifically through Remote Procedure Calls (RPC) and sockets, detailing both TCP and UDP communication methods in Java.

Uploaded by

mohamedmechria02
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

M1IL - Advanced Operating Systems

3rd chapter

Inter-Process
Communication
Presented by: Abdelaziz Kella
❏ Inter process communication (IPC) is a mechanism
which allows processes to communicate with each
Interaction other and synchronize their actions. Processes within

Among a system may be:

Independent process Co-operating process


Processes ● A process is independent if ● A process is co-operating
it cannot affect or be if it can affect or be
affected by the other affected by the other
processes executing in the processes executing in the
system system.

● Any process that does not ● Any process that share


share data with any other data with any other
process is IP process is CP

❏ Reasons for cooperating processes:


❏ Information sharing
❏ Computation speedup
❏ Modularity
❏ Convenience
❏ In a multi-process application these are the
various degrees of interaction:
Interaction 1. Competing processes: Processes

Among themselves do not share anything. But OS


has to share the system resources among

Processes these processes “competing” for system


resources such as disk, file or printer.

Co-operating processes : Results of one or


more processes may be needed for another
process.

2. Co-operation by sharing : Example:


Sharing of an IO buffer. Concept of critical
section (e.g Critical section & Mutual
exclusion)
3. Co-operation by communication :
Example: typically no data sharing, but
co-ordination thru’ synchronization
becomes essential in certain applications.
Types of IPC Mechanisms

IPC mechanisms can be categorized into:

❏ Shared Memory: - Processes access a common


memory space for communication

❏ Semaphores: - Used for controlling access to


shared resources and synchronization

❏ Message Passing: - Processes communicate by


sending and receiving messages
Unicast vs MultiCast

❏ In distributed computing, two or more processes


engage in IPC using a protocol agreed upon by the
processes.

❏ A process may be a sender at some points during a


protocol, a receiver at other points.

❏ When communication is from one process


to a single other process, the IPC is said to
be a unicast, e.g., Socket communication.

❏ When communication is from one process


to a group of processes, the IPC is said to
be a multicast, e.g., Publish/Subscribe
Message model, a topic that we will
explore in a later chapter.
Types of IPC communication

❏ The IPC operations may provide the


synchronization necessary using blocking. A
blocking operation issued by a process will block
further processing of the process until the
operation is fulfilled.

❏ Alternatively, IPC operations may be


asynchronous or nonblocking. An asynchronous
operation issued by a process will not block further
processing of the process. Instead, the process is
free to proceed with its processing, and may
optionally be notified by the system when the
operation is fulfilled.
Types of IPC communication
Message Passing: Concepts and Examples

Fundamentals Practical Examples

Synchronous Communication: Sender waits for Client-Server Models: Web applications using
the receiver to acknowledge receipt message passing for requests and responses
Asynchronous Communication: Sender continues Microservices: Services communicate via
without waiting for acknowledgment messages in distributed systems
IPC in Networking

Context of Networking: - IPC concepts extend to


processes communicating over a network

❏ Remote Procedure Calls RPC / Java RMI


Remote Method Invocation): Allows a program to
execute a procedure on another address space

❏ Sockets

❏ HTTP requests/responses and Its variants


Remote Procedure Calls

❏ These are interprocess communication techniques


that are used for client/server based applications.
A remote procedure call is also known as a
subroutine call or a function call.

❏ A client has a request that the RPC translates and


sends to the server. This request may be a
procedure or a function call to a remote server.
When the server receives the request, it sends the
required response back to the client.
Sockets

❏ Sockets facilitate communication between two


processes on the same machine or different
machines.

❏ They are used in a client/server framework and


consist of the IP address and port number. Many
application protocols use sockets for data
connection and data transfer between a client and
a server.
Sockets

❏ Sockets need to be bound to a port number and an


internet address in order to send and receive
messages.

❏ Each socket has a transport protocol TCP or UDP.

❏ Interprocess communication consists of


transmitting a message between a socket in one
process and a socket in another process.
TCP Stream communication

❏ The API to the TCP protocol provides the


abstraction of a stream of bytes to be written to or
read from.

❏ Characteristics of the stream abstraction:

❏ Message sizes
❏ Lost messages
❏ Flow control
❏ Message destinations

❏ Many services that run over TCP connections, with


reserved port number are:
❏ HTTP Hypertext Transfer Protocol)
❏ FTP File Transfer Protocol)
❏ Telnet
❏ SMTP Simple Mail Transfer Protocol)
Java implementation of TCP Streams

❏ The Java interface to TCP streams is provided in the


classes:

❏ ServerSocket

❏ It is used by a server to create a


socket at server port to listen for
connect requests from clients.

❏ Socket

❏ It is used by a pair of processes with


a connection.
❏ The client uses a constructor to
create a socket and connect it to the
remote host and port of a server.
❏ It provides methods for accessing
input and output streams associated
with a socket.
Java implementation of TCP Streams
UDP Datagram communication
❏ UDP datagram properties
❏ No guarantee of order preservation
❏ Message loss and duplications are possible

❏ Necessary steps
❏ Creating a socket
❏ Binding a socket to a port and local Internet
address
❏ A client binds to any free local port
❏ A server binds to a server port

❏ Blocking
❏ Send: non-blocking
❏ upon arrival, message is placed in a
queue for the socket that is bound to
the destination port.
❏ Receive: blocking
❏ Pre-emption by timeout possible
❏ If process wishes to continue while
waiting for packet, use separate thread
UDP Datagram communication flow
Java implementation of UDP Datagrams

❏ The Java API provides datagram communication by two


classes:

1. DatagramPacket
❏ It provides a constructor to make an array of
bytes comprising:
Message content
Length of message
Internet address
Local port number

❏ It provides another similar constructor for


receiving a message.


Java implementation of UDP Datagrams

❏ The Java API provides datagram communication by two


classes:

2. DatagramSocket

❏ This class supports sockets for sending


and receiving UDP datagram.

❏ It provides a constructor with port number


as argument.

❏ No-argument constructor is used to


choose a free local port.

❏ DatagramSocket methods are:


✓ send and receive
✓ setSoTimeout
✓ connect
Relationship between DatagramPacket &
DatagramSocket

You might also like