SlideShare a Scribd company logo
1 of 30
Operating System
Lecture 4 AND LECTURE 5
[These slides are adapted from Operating System Concepts,
Silberschatz and Galvin © 2015]
Process Management
Processes Communication
Lecture Outcomes
• Understanding of:
• the notion of a process -- a program in execution, which forms the basis of all
computation
• the various features of processes, including scheduling, creation and
termination, and communication
• Inter-process communication using shared memory and message passing
How do processes
communicate with each
other?
Cooperating Processes
● Processes within a computer system may be independent or cooperating.
● Independent Process
● Cannot affect or be affected by the execution of another process.
● Cooperating Process
● Can affect or be affected by other processes, also includes the sharing data.
● Cooperating processes need interprocess communication (IPC).
Interprocess Communication (IPC)
● Reasons for cooperating processes:
• Several users may be interested in the same piece of
information (e.g. a shared file).
Information
Sharing
• If speedup the processing of a task, break it into subtasks,
so each can be executed in parallel.
Computation
Speedup
• Construct system in modular fashion, dividing the system
functions into separate processes.
Modularity
Convenience
•Allow individual user to work on many tasks at the same
time.
Interprocess Communication (IPC)
● Two models:
a) Shared-Memory
b) Message Passing
(a) (b)
Shared-Memory
● A region of memory that is shared by the cooperating processes is established.
● This region usually resides in the address space of the process that is creating it.
● The processes can then exchange information by reading and writing data to the shared
region.
OS (Kernel)
Process A
Process B
Main Memory
Shared
Memory
Shared-Memory
● Typically, the producer-consumer problem is often used to explain the shared-memory
model.
● Similar to the paradigm of cooperating processes, where producer (a process) produces
information that will be consumed by a consumer (another process).
Buffer
(Shared Memory)
Produce
r
Consume
r
Process A
Process B
Shared-Memory
Buffer
(Shared Memory)
Process A
Process B
Producer
Consumer
Put
Consume
PASS
Shared-Memory
Buffer
(Shared Memory)
Process A
Process B
Producer
Consumer
Put
Consume
FAIL…
??? Empty
???
Shared-Memory
●The producer and the consumer must be synchronized.
● Two cooperating processes must be synchronized.
●Consumer should not consume an item that has not been produced by the producer.
● A process should not read the data until it has been produced (or updated) by another
process.
Message Passing
● Another mechanism for processes to communicate.
● The message passing facility provides at least two operations:
● send(message)
● receive(message)
● Message can be in fixed or variable size.
Message Passing
● If message is in fixed size:
● Easier for system implementation.
● Harder for programmer.
● If message is in variable size:
● Harder for system implementation
● Easier for programmer.
Example
● Fixed Size
● send( );
● send(“Morni”);
● send(“ng”);
● Variable Size
● send( )
Good Morning
“Good ”
Packet
Transmit
“Good Morning”
“Good ”
“Morni”
“ng ”
System
Implementation
Transmit
Transmit
Transmit
1 Packet:5 Chars
System
Implementation
Message Passing Model
● When processes want to communicate, they need to:
1) Establish a communication link between them.
2) Exchange messages via the send or receive operation.
● Two types of communication:
1) Direct Communication
2) Indirect Communication
Direct Communication
● 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.
● Between each pair of processes there exists exactly one link.
● The link is usually bi-directional.
● Disadvantages:
● Must know the name (ID) of the process that is going to send or receive the message
(hard-coding is not desirable)
Indirect Communication
● Messages are sent to and received from mailboxes or 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
● To communicate using indirect communication:
1) Create a new mailbox.
2) Send and receive messages through mailbox
3) Destroy the mailbox.
● Processes do not have to name each other explicitly:
● send(A, message):
● Send a message to mailbox A.
● receive(A, message):
● Receive a message from mailbox A.
Indirect Communication
● Assuming that we have three processes, P1, P2, and P3 that sharing the mailbox A.
If P1 sends a message, then P2 and P3 run receive from A. Who gets the message?
● It depends on how the OS want to handle it.
1) Allow a link to be associated with at most two processes
2) Allow only one process at a time to execute a receive operation.
3) Allow the system to select arbitrarily the receiver.
● Sender will be notified who was the receiver.
Direct and Indirect Communication
● Direct Communication
● Indirect Communication
P Q
To
Q
From P
P Q
R
Mailbox
A
To A
From A
From A
Implementation of Message Passing
Blocking (Synchronous) Non-blocking (Asynchronous)
Blocking Send:
Sender is blocked until the message is
received by the receiving process or by
the mailbox.
Non-blocking Send:
Sender sends the message and resumes
operations.
Blocking Receive:
Receiver is blocked until a message is
available.
Non-blocking Receive:
Receiver can retrieve either a valid
message or a null.
Synchronous (Blocking Send)
Sender Receiver
1. send(“I’m hungry”) Sending…
Can I send
another
message?
NO
Suspende
d
Ya, I received and
read your
message.
Done
OK
2. send(“Lunch?”)
Have to wait for confirmation from the receiver.
Synchronous (Blocking Receive)
Sender Receiver
send(“I’m hungry”) Waiting
…
Suspende
d
Can I back off and
do other things?
NO
Done OK
Have to wait until there is a message to receive.
receive(Sender)
Asynchronous (Non-blocking Send)
Sender Receiver
1. send(“I’m hungry”)
Sending…
Can I send
another
message?
OK
2. send(“Lunch?”) Buffer
3. send(“Where?”)
Asynchronous (Non-blocking Receive)
Sender Receiver
return null
Buffer (Empty)
receive(Sender)
Can I back off and
do other things?
OK
≈Queue
Buffering
● Messages exchanged by processes reside in a temporary queue (buffer).
● Basically, the queue can be implemented in three ways:
1. Zero Capacity – Zero Messages
● The link cannot have any messages waiting in it.
● The sender needs to block until the recipient receives the message.
2. Bounded Capacity – Finite Length of n Messages
● If the queue not full, sender places the message in the queue.
● Sender can then continue execution without waiting.
● If the queue is full, sender has to block.
3. Unbounded Capacity – Infinite Length of Messages
● Sender will never blocks.
Shared-Memory v.s. Message Passing
Shared-Memory Message Passing
Faster in exchanging data. System calls
are required to establish the shared-
memory regions. Once is established, no
assistance is needed from the kernel.
Useful for exchanging smaller amount of
data. Slower because typically it is
implemented using system calls that
requires kernel intervention.
Convenience for communication within
the same system.
Easier to implement for intercomputer
communication.
Review Questions
• Provide at least three possible states a process may be in.
• What is a Process Control Block (PCB) ?
• What is the degree of multiprogramming?
• What is the term that describes saving the state of one process, and
restoring the state of another?
• What system call creates and terminates a process on UNIX systems
and Windows systems?
• What are the two system calls used with message-passing systems?
Thank you
Insert the title of your subtitle Here

More Related Content

Similar to Chapter 3b- Process Communication (1) (1)(1) (1).pptx

interprocess-communication.pdf
interprocess-communication.pdfinterprocess-communication.pdf
interprocess-communication.pdfAmarSingh21897
 
5_Interprocess Communication.pptx
5_Interprocess Communication.pptx5_Interprocess Communication.pptx
5_Interprocess Communication.pptxssuser2adefd1
 
Ch4 OS
Ch4 OSCh4 OS
Ch4 OSC.U
 
Inter process communication by Dr.C.R.Dhivyaa, Assistant Professor,Kongu Engi...
Inter process communication by Dr.C.R.Dhivyaa, Assistant Professor,Kongu Engi...Inter process communication by Dr.C.R.Dhivyaa, Assistant Professor,Kongu Engi...
Inter process communication by Dr.C.R.Dhivyaa, Assistant Professor,Kongu Engi...Dhivyaa C.R
 
Module-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.ppt
Module-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.pptModule-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.ppt
Module-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.pptKAnurag2
 
Message Passing Systems
Message Passing SystemsMessage Passing Systems
Message Passing SystemsNehaHaroon1
 
Mumbai MuleSoft Meetup #20
Mumbai MuleSoft Meetup #20Mumbai MuleSoft Meetup #20
Mumbai MuleSoft Meetup #20Akshata Sawant
 
Message Passing, Remote Procedure Calls and Distributed Shared Memory as Com...
Message Passing, Remote Procedure Calls and  Distributed Shared Memory as Com...Message Passing, Remote Procedure Calls and  Distributed Shared Memory as Com...
Message Passing, Remote Procedure Calls and Distributed Shared Memory as Com...Sehrish Asif
 
Storing the real world data
Storing the real world dataStoring the real world data
Storing the real world dataAthira Mukundan
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process CommunicationAdeel Rasheed
 
Producer Consumer Problem in C explained.ppt
Producer Consumer Problem in C explained.pptProducer Consumer Problem in C explained.ppt
Producer Consumer Problem in C explained.pptossama8
 

Similar to Chapter 3b- Process Communication (1) (1)(1) (1).pptx (20)

interprocess-communication.pdf
interprocess-communication.pdfinterprocess-communication.pdf
interprocess-communication.pdf
 
5_Interprocess Communication.pptx
5_Interprocess Communication.pptx5_Interprocess Communication.pptx
5_Interprocess Communication.pptx
 
Ch4 OS
Ch4 OSCh4 OS
Ch4 OS
 
OS_Ch4
OS_Ch4OS_Ch4
OS_Ch4
 
Process
ProcessProcess
Process
 
OSCh4
OSCh4OSCh4
OSCh4
 
Ch4
Ch4Ch4
Ch4
 
Ch03
Ch03Ch03
Ch03
 
Chapter 3 - Processes
Chapter 3 - ProcessesChapter 3 - Processes
Chapter 3 - Processes
 
Inter process communication by Dr.C.R.Dhivyaa, Assistant Professor,Kongu Engi...
Inter process communication by Dr.C.R.Dhivyaa, Assistant Professor,Kongu Engi...Inter process communication by Dr.C.R.Dhivyaa, Assistant Professor,Kongu Engi...
Inter process communication by Dr.C.R.Dhivyaa, Assistant Professor,Kongu Engi...
 
Module-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.ppt
Module-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.pptModule-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.ppt
Module-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.ppt
 
Lecture 5 inter process communication
Lecture 5 inter process communicationLecture 5 inter process communication
Lecture 5 inter process communication
 
Message Passing Systems
Message Passing SystemsMessage Passing Systems
Message Passing Systems
 
Mumbai MuleSoft Meetup #20
Mumbai MuleSoft Meetup #20Mumbai MuleSoft Meetup #20
Mumbai MuleSoft Meetup #20
 
Message Passing, Remote Procedure Calls and Distributed Shared Memory as Com...
Message Passing, Remote Procedure Calls and  Distributed Shared Memory as Com...Message Passing, Remote Procedure Calls and  Distributed Shared Memory as Com...
Message Passing, Remote Procedure Calls and Distributed Shared Memory as Com...
 
Storing the real world data
Storing the real world dataStoring the real world data
Storing the real world data
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 
Ch3
Ch3Ch3
Ch3
 
3 processes
3 processes3 processes
3 processes
 
Producer Consumer Problem in C explained.ppt
Producer Consumer Problem in C explained.pptProducer Consumer Problem in C explained.ppt
Producer Consumer Problem in C explained.ppt
 

Recently uploaded

Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxolyaivanovalion
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023ymrp368
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfRachmat Ramadhan H
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...SUHANI PANDEY
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...shivangimorya083
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...amitlee9823
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Valters Lauzums
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfMarinCaroMartnezBerg
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...shambhavirathore45
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxolyaivanovalion
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...amitlee9823
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...amitlee9823
 

Recently uploaded (20)

Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 

Chapter 3b- Process Communication (1) (1)(1) (1).pptx

  • 1. Operating System Lecture 4 AND LECTURE 5 [These slides are adapted from Operating System Concepts, Silberschatz and Galvin © 2015]
  • 3. Lecture Outcomes • Understanding of: • the notion of a process -- a program in execution, which forms the basis of all computation • the various features of processes, including scheduling, creation and termination, and communication • Inter-process communication using shared memory and message passing
  • 4. How do processes communicate with each other?
  • 5. Cooperating Processes ● Processes within a computer system may be independent or cooperating. ● Independent Process ● Cannot affect or be affected by the execution of another process. ● Cooperating Process ● Can affect or be affected by other processes, also includes the sharing data. ● Cooperating processes need interprocess communication (IPC).
  • 6. Interprocess Communication (IPC) ● Reasons for cooperating processes: • Several users may be interested in the same piece of information (e.g. a shared file). Information Sharing • If speedup the processing of a task, break it into subtasks, so each can be executed in parallel. Computation Speedup • Construct system in modular fashion, dividing the system functions into separate processes. Modularity Convenience •Allow individual user to work on many tasks at the same time.
  • 7. Interprocess Communication (IPC) ● Two models: a) Shared-Memory b) Message Passing (a) (b)
  • 8. Shared-Memory ● A region of memory that is shared by the cooperating processes is established. ● This region usually resides in the address space of the process that is creating it. ● The processes can then exchange information by reading and writing data to the shared region. OS (Kernel) Process A Process B Main Memory Shared Memory
  • 9. Shared-Memory ● Typically, the producer-consumer problem is often used to explain the shared-memory model. ● Similar to the paradigm of cooperating processes, where producer (a process) produces information that will be consumed by a consumer (another process). Buffer (Shared Memory) Produce r Consume r Process A Process B
  • 10. Shared-Memory Buffer (Shared Memory) Process A Process B Producer Consumer Put Consume PASS
  • 11. Shared-Memory Buffer (Shared Memory) Process A Process B Producer Consumer Put Consume FAIL… ??? Empty ???
  • 12. Shared-Memory ●The producer and the consumer must be synchronized. ● Two cooperating processes must be synchronized. ●Consumer should not consume an item that has not been produced by the producer. ● A process should not read the data until it has been produced (or updated) by another process.
  • 13. Message Passing ● Another mechanism for processes to communicate. ● The message passing facility provides at least two operations: ● send(message) ● receive(message) ● Message can be in fixed or variable size.
  • 14. Message Passing ● If message is in fixed size: ● Easier for system implementation. ● Harder for programmer. ● If message is in variable size: ● Harder for system implementation ● Easier for programmer.
  • 15. Example ● Fixed Size ● send( ); ● send(“Morni”); ● send(“ng”); ● Variable Size ● send( ) Good Morning “Good ” Packet Transmit “Good Morning” “Good ” “Morni” “ng ” System Implementation Transmit Transmit Transmit 1 Packet:5 Chars System Implementation
  • 16. Message Passing Model ● When processes want to communicate, they need to: 1) Establish a communication link between them. 2) Exchange messages via the send or receive operation. ● Two types of communication: 1) Direct Communication 2) Indirect Communication
  • 17. Direct Communication ● 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. ● Between each pair of processes there exists exactly one link. ● The link is usually bi-directional. ● Disadvantages: ● Must know the name (ID) of the process that is going to send or receive the message (hard-coding is not desirable)
  • 18. Indirect Communication ● Messages are sent to and received from mailboxes or 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.
  • 19. Indirect Communication ● To communicate using indirect communication: 1) Create a new mailbox. 2) Send and receive messages through mailbox 3) Destroy the mailbox. ● Processes do not have to name each other explicitly: ● send(A, message): ● Send a message to mailbox A. ● receive(A, message): ● Receive a message from mailbox A.
  • 20. Indirect Communication ● Assuming that we have three processes, P1, P2, and P3 that sharing the mailbox A. If P1 sends a message, then P2 and P3 run receive from A. Who gets the message? ● It depends on how the OS want to handle it. 1) Allow a link to be associated with at most two processes 2) Allow only one process at a time to execute a receive operation. 3) Allow the system to select arbitrarily the receiver. ● Sender will be notified who was the receiver.
  • 21. Direct and Indirect Communication ● Direct Communication ● Indirect Communication P Q To Q From P P Q R Mailbox A To A From A From A
  • 22. Implementation of Message Passing Blocking (Synchronous) Non-blocking (Asynchronous) Blocking Send: Sender is blocked until the message is received by the receiving process or by the mailbox. Non-blocking Send: Sender sends the message and resumes operations. Blocking Receive: Receiver is blocked until a message is available. Non-blocking Receive: Receiver can retrieve either a valid message or a null.
  • 23. Synchronous (Blocking Send) Sender Receiver 1. send(“I’m hungry”) Sending… Can I send another message? NO Suspende d Ya, I received and read your message. Done OK 2. send(“Lunch?”) Have to wait for confirmation from the receiver.
  • 24. Synchronous (Blocking Receive) Sender Receiver send(“I’m hungry”) Waiting … Suspende d Can I back off and do other things? NO Done OK Have to wait until there is a message to receive. receive(Sender)
  • 25. Asynchronous (Non-blocking Send) Sender Receiver 1. send(“I’m hungry”) Sending… Can I send another message? OK 2. send(“Lunch?”) Buffer 3. send(“Where?”)
  • 26. Asynchronous (Non-blocking Receive) Sender Receiver return null Buffer (Empty) receive(Sender) Can I back off and do other things? OK ≈Queue
  • 27. Buffering ● Messages exchanged by processes reside in a temporary queue (buffer). ● Basically, the queue can be implemented in three ways: 1. Zero Capacity – Zero Messages ● The link cannot have any messages waiting in it. ● The sender needs to block until the recipient receives the message. 2. Bounded Capacity – Finite Length of n Messages ● If the queue not full, sender places the message in the queue. ● Sender can then continue execution without waiting. ● If the queue is full, sender has to block. 3. Unbounded Capacity – Infinite Length of Messages ● Sender will never blocks.
  • 28. Shared-Memory v.s. Message Passing Shared-Memory Message Passing Faster in exchanging data. System calls are required to establish the shared- memory regions. Once is established, no assistance is needed from the kernel. Useful for exchanging smaller amount of data. Slower because typically it is implemented using system calls that requires kernel intervention. Convenience for communication within the same system. Easier to implement for intercomputer communication.
  • 29. Review Questions • Provide at least three possible states a process may be in. • What is a Process Control Block (PCB) ? • What is the degree of multiprogramming? • What is the term that describes saving the state of one process, and restoring the state of another? • What system call creates and terminates a process on UNIX systems and Windows systems? • What are the two system calls used with message-passing systems?
  • 30. Thank you Insert the title of your subtitle Here