SlideShare a Scribd company logo
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Chapter 3: Processes
3.2 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Cooperating Processes
 Processes within a system may be independent or cooperating
 When processes execute they produce some computational results
 Independent process cannot affect (or be affected) by such results of
another process
 Cooperating process can affect (or be affected) by such results of
another process
 Advantages of process cooperation
 Information sharing
 Computation speed-up
 Modularity
 Convenience
3.3 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Interprocess Communication
 For fast exchange of information, cooperating processes need some
interprocess communication (IPC) mechanisms. Two models of IPC
 Shared memory: A region of memory that is shared by cooperating
processes is established. Processes can then exchange information
by reading and writing data to the shared region
 Message passing: Communication takes place by means of
messages exchanged between the cooperating processes.
Processes communicate with each other without resorting to shared
variables. (pipes, FIFO, sockets, message queues, semaphores, signals)
3.4 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Producer-Consumer Problem
 Producer-consumer problem – a common paradigm for cooperating
processes where
 Producer process produces some information incrementally
 Consumer process consumes this information as it becomes
available
 Challenge:
 Producer and consumer should run concurrently and efficiently
 Producer and consumer must be synchronized
 Consumer cannot consume an item before it is produced
 Shared-memory solution to producer-consumer
 Uses a buffer in shared memory to exchange information
 unbounded-buffer: assumes no practical limit on the buffer size
 bounded-buffer assumes a fixed buffer size
3.5 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Bounded-Buffer – Shared-Memory Solution
#define BUFFER_SIZE 5 typedef struct{ ---- } item; item buffer[BUFFER_SIZE];
int in = 0; //points to location where next item will be placed, will be used by producer
process
int out = 0; //points to location from where item is to be consumed will be used by consumer
process
int ctr = 0;
while(1)
{
nextProduced = getItem();
while(ctr == BUFFER_SIZE)
; //do nothing
buffer[in] = nextProduced;
in = (in + 1) % BUFFER_SIZE;
ctr++; }
Producer Process Consumer
Process
item nextProduced; item
nextConsumed; while(1)
{
while(ctr == 0)
; //do nothing nextConsumed =
buffer[out];
out = (out + 1) % BUFFER_SIZE;
ctr--;
}
3.6 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Interprocess Communication – 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)
 receive(message)
 The message size is either fixed or variable
3.7 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Message Passing (Cont.)
 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 (buffer size) of a link?
 Is the size of a message that the link can accommodate fixed or
variable?
 Is a link unidirectional or bi-directional?
3.8 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Message Passing (Cont.)
 Logical implementation of communication link
 Direct or indirect
 Synchronous or asynchronous
 Automatic or explicit buffering
3.9 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
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 a direct 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
3.10 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
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 an indirect 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
3.11 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
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
3.12 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Indirect Communication
 Mailbox sharing issues
 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.
3.13 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Synchronization
 Message passing may be either
 Blocking, or
 Non-blocking
 Blocking is considered synchronous
 Blocking send -- the sender is blocked until the message is received
 Blocking receive -- the receiver is blocked until a message is available
 Non-blocking is considered asynchronous
 Non-blocking send -- the sender sends the message and continues
 Non-blocking receive -- the receiver receives:
 A valid message, or
 Null message
 Different combinations possible
 If both send and receive are blocking – called a rendezvous
3.14 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Buffering in Message-Passing
 Queue of messages is attached to the link.
 Implemented in one of three ways
1. Zero capacity – no messages are queued on a link.
- Sender must wait for receiver (rendezvous)
2. Bounded capacity – finite length of n messages
- Sender must wait if link full
3. Unbounded capacity – infinite length
- Sender never waits
3.15 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Pipes
 Acts as a conduit allowing two processes to communicate
 Ordinary pipes – cannot be accessed from outside the process
that created it. Typically, a parent process creates a pipe and
uses it to communicate with a child process that it created.
 Named pipes – can be accessed without a parent-child
relationship.
3.16 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Ordinary Pipes
 Ordinary pipes – cannot be accessed from outside the process that
created it. Typically, a parent process creates a pipe and uses it to
communicate with a child process that it created.
 Ordinary Pipes allow communication in standard producer-consumer
style
 Producer writes to one end (the write-end of the pipe)
 Consumer reads from the other end (the read-end of the pipe)
 Ordinary pipes are therefore unidirectional
 Windows calls these anonymous pipes
3.17 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Named Pipes
 Named Pipes can be accessed without a parent-child
relationship.
 They are more powerful than ordinary pipes
 Communication is bidirectional
 No parent-child relationship is necessary between the
communicating processes
 Several processes can use the named pipe for communication
3.18 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Sockets
 A socket are used for communication between related or
unrelated processes on the same or different UNIX systems.

More Related Content

Similar to Lec 07 process in Operating system .ppt (20)

PPT
Ch4 OS
C.U
 
PPT
Process
Sachin MK
 
PPT
OSCh4
Joe Christensen
 
PPT
Chapter 3 - Processes
Wayne Jones Jnr
 
PPTX
5_Interprocess Communication.pptx
ssuser2adefd1
 
PPTX
OPERATING SYSTEM UNIT 2 for paper and knowlekdge
EverywhereName
 
PDF
Lecture-4_Process Management.pdf
Harika Pudugosula
 
PDF
interprocess-communication.pdf
AmarSingh21897
 
PPTX
Operating system 19 interacting processes and ipc
Vaibhav Khanna
 
PPT
Ch03 processes
Nazir Ahmed
 
PPTX
3 processes
ari9_dutta
 
PPT
Inter-Process communication in Operating System.ppt
NitihyaAshwinC
 
PPT
Module-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.ppt
KAnurag2
 
PPT
OS UNIT2.ppt
DHANABALSUBRAMANIAN
 
PDF
Lecture 3_Processes in Operating Systems.pdf
jamesLau66
 
PDF
Ch3OperSys
Dwight Sabio
 
PDF
OperatingSystemChp3
Dwight Sabio
 
PPTX
CSC 2205 OS Lecture 07 IPC on 7-10-2024 New.pptx
omer472913
 
Ch4 OS
C.U
 
Process
Sachin MK
 
Chapter 3 - Processes
Wayne Jones Jnr
 
5_Interprocess Communication.pptx
ssuser2adefd1
 
OPERATING SYSTEM UNIT 2 for paper and knowlekdge
EverywhereName
 
Lecture-4_Process Management.pdf
Harika Pudugosula
 
interprocess-communication.pdf
AmarSingh21897
 
Operating system 19 interacting processes and ipc
Vaibhav Khanna
 
Ch03 processes
Nazir Ahmed
 
3 processes
ari9_dutta
 
Inter-Process communication in Operating System.ppt
NitihyaAshwinC
 
Module-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.ppt
KAnurag2
 
OS UNIT2.ppt
DHANABALSUBRAMANIAN
 
Lecture 3_Processes in Operating Systems.pdf
jamesLau66
 
Ch3OperSys
Dwight Sabio
 
OperatingSystemChp3
Dwight Sabio
 
CSC 2205 OS Lecture 07 IPC on 7-10-2024 New.pptx
omer472913
 

Recently uploaded (20)

PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
Designing Production-Ready AI Agents
Kunal Rai
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Advancing WebDriver BiDi support in WebKit
Igalia
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Biography of Daniel Podor.pdf
Daniel Podor
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Designing Production-Ready AI Agents
Kunal Rai
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Advancing WebDriver BiDi support in WebKit
Igalia
 
Ad

Lec 07 process in Operating system .ppt

  • 1. Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Chapter 3: Processes
  • 2. 3.2 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Cooperating Processes  Processes within a system may be independent or cooperating  When processes execute they produce some computational results  Independent process cannot affect (or be affected) by such results of another process  Cooperating process can affect (or be affected) by such results of another process  Advantages of process cooperation  Information sharing  Computation speed-up  Modularity  Convenience
  • 3. 3.3 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Interprocess Communication  For fast exchange of information, cooperating processes need some interprocess communication (IPC) mechanisms. Two models of IPC  Shared memory: A region of memory that is shared by cooperating processes is established. Processes can then exchange information by reading and writing data to the shared region  Message passing: Communication takes place by means of messages exchanged between the cooperating processes. Processes communicate with each other without resorting to shared variables. (pipes, FIFO, sockets, message queues, semaphores, signals)
  • 4. 3.4 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Producer-Consumer Problem  Producer-consumer problem – a common paradigm for cooperating processes where  Producer process produces some information incrementally  Consumer process consumes this information as it becomes available  Challenge:  Producer and consumer should run concurrently and efficiently  Producer and consumer must be synchronized  Consumer cannot consume an item before it is produced  Shared-memory solution to producer-consumer  Uses a buffer in shared memory to exchange information  unbounded-buffer: assumes no practical limit on the buffer size  bounded-buffer assumes a fixed buffer size
  • 5. 3.5 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Bounded-Buffer – Shared-Memory Solution #define BUFFER_SIZE 5 typedef struct{ ---- } item; item buffer[BUFFER_SIZE]; int in = 0; //points to location where next item will be placed, will be used by producer process int out = 0; //points to location from where item is to be consumed will be used by consumer process int ctr = 0; while(1) { nextProduced = getItem(); while(ctr == BUFFER_SIZE) ; //do nothing buffer[in] = nextProduced; in = (in + 1) % BUFFER_SIZE; ctr++; } Producer Process Consumer Process item nextProduced; item nextConsumed; while(1) { while(ctr == 0) ; //do nothing nextConsumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; ctr--; }
  • 6. 3.6 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Interprocess Communication – 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)  receive(message)  The message size is either fixed or variable
  • 7. 3.7 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Message Passing (Cont.)  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 (buffer size) of a link?  Is the size of a message that the link can accommodate fixed or variable?  Is a link unidirectional or bi-directional?
  • 8. 3.8 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Message Passing (Cont.)  Logical implementation of communication link  Direct or indirect  Synchronous or asynchronous  Automatic or explicit buffering
  • 9. 3.9 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 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 a direct 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
  • 10. 3.10 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 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 an indirect 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
  • 11. 3.11 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 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
  • 12. 3.12 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Indirect Communication  Mailbox sharing issues  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.
  • 13. 3.13 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Synchronization  Message passing may be either  Blocking, or  Non-blocking  Blocking is considered synchronous  Blocking send -- the sender is blocked until the message is received  Blocking receive -- the receiver is blocked until a message is available  Non-blocking is considered asynchronous  Non-blocking send -- the sender sends the message and continues  Non-blocking receive -- the receiver receives:  A valid message, or  Null message  Different combinations possible  If both send and receive are blocking – called a rendezvous
  • 14. 3.14 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Buffering in Message-Passing  Queue of messages is attached to the link.  Implemented in one of three ways 1. Zero capacity – no messages are queued on a link. - Sender must wait for receiver (rendezvous) 2. Bounded capacity – finite length of n messages - Sender must wait if link full 3. Unbounded capacity – infinite length - Sender never waits
  • 15. 3.15 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Pipes  Acts as a conduit allowing two processes to communicate  Ordinary pipes – cannot be accessed from outside the process that created it. Typically, a parent process creates a pipe and uses it to communicate with a child process that it created.  Named pipes – can be accessed without a parent-child relationship.
  • 16. 3.16 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Ordinary Pipes  Ordinary pipes – cannot be accessed from outside the process that created it. Typically, a parent process creates a pipe and uses it to communicate with a child process that it created.  Ordinary Pipes allow communication in standard producer-consumer style  Producer writes to one end (the write-end of the pipe)  Consumer reads from the other end (the read-end of the pipe)  Ordinary pipes are therefore unidirectional  Windows calls these anonymous pipes
  • 17. 3.17 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Named Pipes  Named Pipes can be accessed without a parent-child relationship.  They are more powerful than ordinary pipes  Communication is bidirectional  No parent-child relationship is necessary between the communicating processes  Several processes can use the named pipe for communication
  • 18. 3.18 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Sockets  A socket are used for communication between related or unrelated processes on the same or different UNIX systems.