0% found this document useful (0 votes)
22 views

Lec 9 IPC, Message Passing

This document discusses inter-process communication (IPC) methods, including shared memory and message passing. It describes shared memory as an area of memory shared among processes that wish to communicate, with major issues being synchronization. Message passing is defined as a mechanism where processes communicate without shared variables using send and receive operations through communication links or mailboxes. Different implementations of message passing involve physical links like shared memory or networks, and logical aspects like direct/indirect and synchronous/asynchronous communication.

Uploaded by

2412arjitchauhan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Lec 9 IPC, Message Passing

This document discusses inter-process communication (IPC) methods, including shared memory and message passing. It describes shared memory as an area of memory shared among processes that wish to communicate, with major issues being synchronization. Message passing is defined as a mechanism where processes communicate without shared variables using send and receive operations through communication links or mailboxes. Different implementations of message passing involve physical links like shared memory or networks, and logical aspects like direct/indirect and synchronous/asynchronous communication.

Uploaded by

2412arjitchauhan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

CSET209 OPERATING

SYSTEM

Lecture 9 Inter-process Communication


Deepika Vatsa
OUTLINE

 Inter process communication


 Shared Memory Method
 Message passing method and its types
INTER PROCESS COMMUNICATION (IPC)

 Processes within a system may be independent or cooperating


 Cooperating process can affect or be affected by other processes, including sharing data
 IPC is a mechanism where one process communicates with another process
 Communication: Exchange of data
 Example:

In linux, ls command lists the filenames of files in a directory


And lpr command prints the input using printer
So, ls | lpr will print the filenames of files in a directory
Here, pipe (|) acts as an IPC between two processes ls and lpr
WHY IPC?

 Information sharing
 Resource sharing
 Computation speedup
 Synchronization
 Modularity
 Convenience
2 MODELS OF IPC MECHANISMS

 Message Passing: Message is

passed using a queue

 Shared memory

IMG
SRC: https://www.os-book.com/OS9/slide-dir/PPT-dir/ch3.ppt
IPC: SHARED MEMORY

 An area of memory shared among the processes that wish to communicate


 The communication is under the control of the users processes not the operating system.
 Major issues is to provide mechanism that will allow the user processes to synchronize
their actions when they access shared memory.
IPC: MESSAGE PASSING

 Mechanism for processes to communicate and to synchronize their actions


 Message system – processes communicate with each other without resorting to shared
variables
 IPC facility provides two operations: send(message) and receive(message)
 The message size is either fixed or variable
IPC: MESSAGE PASSING
 If processes P and Q wish to communicate, they need to:
 Establish a communication link between them
 Exchange messages via send/receive

 Implementation issues:
 How are links established?
 Can a link be associated with more than two processes?
 How many links can there be between every pair of communicating processes?
 What is the capacity of a link?
 Is the size of a message that the link can accommodate fixed or variable?
 Is a link unidirectional or bi-directional?
IPC: MESSAGE PASSING
 Implementation of communication link

● Physical:
 Shared memory
 Hardware bus
 Network

● Logical:
 Direct or indirect
 Synchronous or asynchronous
 Automatic or explicit buffering
IPC: MESSAGE PASSING

 Processes must name each other explicitly:

● send (P, message) – send a message to process P


● receive(Q, message) – receive a message from process Q

 Properties of communication link

● Links are established automatically


● A link is associated with exactly one pair of communicating processes
● Between each pair there exists exactly one link
● The link may be unidirectional, but is usually bi-directional
INDIRECT COMMUNICATION
 Messages are directed and received from
mailboxes (also referred to as ports)
● Each mailbox has a unique id
● Processes can communicate only if they
share a mailbox
 Properties of communication link

● Link established only if processes share a


common mailbox
● A link may be associated with many
processes
● Each pair of processes may share several
communication links
● Link may be unidirectional or bi-
directional
INDIRECT COMMUNICATION

 Operations

● create a new mailbox (port)


● send and receive messages through mailbox
● destroy a mailbox

 Primitives are defined as:

send(A, message) – send a message to mailbox A


receive(A, message) – receive a message from mailbox A
INDIRECT COMMUNICATION
 Mailbox sharing

● P1, P2, and P3 share mailbox A


● P1, sends; P2 and P3 receive
● Who gets the message?

 Solutions

● Allow a link to be associated with at most two processes


● Allow only one process at a time to execute a receive operation
● Allow the system to select arbitrarily the receiver.
● Sender is notified who the receiver was.
Thank
You

You might also like