SlideShare a Scribd company logo
1 of 34
Silberschatz and Galvin ©19994.1
Module 4: Processes
• Process Concept
• Process Scheduling
• Operation on Processes
• Cooperating Processes
• Interprocess Communication
Silberschatz and Galvin ©19994.2
Process Concept
• An operating system executes a variety of programs:
– Batch system – jobs
– Time-shared systems – user programs or tasks
• Textbook uses the terms job and process almost
interchangeably.
• Process – a program in execution; process execution must
progress in sequential fashion.
• A process includes:
– program counter
– stack
– data section
Silberschatz and Galvin ©19994.3
Process State
• As a process executes, it changes state
– new: The process is being created.
– running: Instructions are being executed.
– waiting: The process is waiting for some event to occur.
– ready: The process is waiting to be assigned to a process.
– terminated: The process has finished execution.
Silberschatz and Galvin ©19994.4
Diagram of Process State
Silberschatz and Galvin ©19994.5
Process Control Block (PCB)
Information associated with each process.
• Process state
• Program counter
• CPU registers
• CPU scheduling information
• Memory-management information
• Accounting information
• I/O status information
Silberschatz and Galvin ©19994.6
Process Control Block (PCB)
Silberschatz and Galvin ©19994.7
CPU Switch From Process to
Process
Silberschatz and Galvin ©19994.8
Process Scheduling Queues
• Job queue – set of all processes in the system.
• Ready queue – set of all processes residing in main memory,
ready and waiting to execute.
• Device queues – set of processes waiting for an I/O device.
• Process migration between the various queues.
Silberschatz and Galvin ©19994.9
Ready Queue And Various I/O Device
Queues
Silberschatz and Galvin ©19994.10
Representation of Process
Scheduling
Silberschatz and Galvin ©19994.11
Schedulers
• Long-term scheduler (or job scheduler) – selects which
processes should be brought into the ready queue.
• Short-term scheduler (or CPU scheduler) – selects which process
should be executed next and allocates CPU.
Silberschatz and Galvin ©19994.12
Addition of Medium Term
Scheduling
Silberschatz and Galvin ©19994.13
Schedulers (Cont.)
• Short-term scheduler is invoked very frequently (milliseconds)
⇒ (must be fast).
• Long-term scheduler is invoked very infrequently (seconds,
minutes) ⇒ (may be slow).
• The long-term scheduler controls the degree of
multiprogramming.
• Processes can be described as either:
– I/O-bound process – spends more time doing I/O than
computations, many short CPU bursts.
– CPU-bound process – spends more time doing
computations; few very long CPU bursts.
Silberschatz and Galvin ©19994.14
Context Switch
• When CPU switches to another process, the system must save
the state of the old process and load the saved state for the new
process.
• Context-switch time is overhead; the system does no useful work
while switching.
• Time dependent on hardware support.
Silberschatz and Galvin ©19994.15
Process Creation
• Parent process creates children processes, which, in turn create
other processes, forming a tree of processes.
• Resource sharing
– Parent and children share all resources.
– Children share subset of parent’s resources.
– Parent and child share no resources.
• Execution
– Parent and children execute concurrently.
– Parent waits until children terminate.
Silberschatz and Galvin ©19994.16
Process Creation (Cont.)
• Address space
– Child duplicate of parent.
– Child has a program loaded into it.
• UNIX examples
– fork system call creates new process
– execve system call used after a fork to replace the
process’ memory space with a new program.
Silberschatz and Galvin ©19994.17
A Tree of Processes On A Typical UNIX
System
Silberschatz and Galvin ©19994.18
Process Termination
• Process executes last statement and asks the operating system
to decide it (exit).
– Output data from child to parent (via wait).
– Process’ resources are deallocated by operating system.
• Parent may terminate execution of children processes (abort).
– Child has exceeded allocated resources.
– Task assigned to child is no longer required.
– Parent is exiting.
Operating system does not allow child to continue if its
parent terminates.
Cascading termination.
Silberschatz and Galvin ©19994.19
Cooperating Processes
• Independent process cannot affect or be affected by the
execution of another process.
• Cooperating process can affect or be affected by the execution of
another process
• Advantages of process cooperation
– Information sharing
– Computation speed-up
– Modularity
– Convenience
Silberschatz and Galvin ©19994.20
Producer-Consumer Problem
• Paradigm for cooperating processes, producer process produces
information that is consumed by a consumer process.
– unbounded-buffer places no practical limit on the size of the
buffer.
– bounded-buffer assumes that there is a fixed buffer size.
Silberschatz and Galvin ©19994.21
Bounded-Buffer – Shared-Memory
Solution
• Shared data
var n;
type item = … ;
var buffer. array [0..n–1] of item;
in, out: 0..n–1;
• Producer process
repeat
…
produce an item in nextp
…
while in+1 mod n = out do no-op;
buffer [in] :=nextp;
in :=in+1 mod n;
until false;
Silberschatz and Galvin ©19994.22
Bounded-Buffer (Cont.)
• Consumer process
repeat
while in = out do no-op;
nextc := buffer [out];
out := out+1 mod n;
…
consume the item in nextc
…
until false;
• Solution is correct, but can only fill up n–1 buffer.
Silberschatz and Galvin ©19994.23
Threads
• A thread (or lightweight process) is a basic unit of CPU utilization;
it consists of:
– program counter
– register set
– stack space
• A thread shares with its peer threads its:
– code section
– data section
– operating-system resources
collectively know as a task.
• A traditional or heavyweight process is equal to a task with one
thread
Silberschatz and Galvin ©19994.24
Threads (Cont.)
• In a multiple threaded task, while one server thread is blocked
and waiting, a second thread in the same task can run.
– Cooperation of multiple threads in same job confers higher
throughput and improved performance.
– Applications that require sharing a common buffer (i.e.,
producer-consumer) benefit from thread utilization.
• Threads provide a mechanism that allows sequential processes
to make blocking system calls while also achieving parallelism.
• Kernel-supported threads (Mach and OS/2).
• User-level threads; supported above the kernel, via a set of
library calls at the user level (Project Andrew from CMU).
• Hybrid approach implements both user-level and kernel-
supported threads (Solaris 2).
Silberschatz and Galvin ©19994.25
Multiple Threads within a Task
Silberschatz and Galvin ©19994.26
Threads Support in Solaris 2
• Solaris 2 is a version of UNIX with support for threads at the
kernel and user levels, symmetric multiprocessing, and
real-time scheduling.
• LWP – intermediate level between user-level threads and
kernel-level threads.
• Resource needs of thread types:
– Kernel thread: small data structure and a stack; thread
switching does not require changing memory access
information – relatively fast.
– LWP: PCB with register data, accounting and memory
information,; switching between LWPs is relatively slow.
– User-level thread: only ned stack and program counter;
no kernel involvement means fast switching. Kernel only
sees the LWPs that support user-level threads.
Silberschatz and Galvin ©19994.27
Solaris 2 Threads
Silberschatz and Galvin ©19994.28
Interprocess Communication (IPC)
• 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) – message size fixed or variable
– receive(message)
• If P and Q wish to communicate, they need to:
– establish a communication link between them
– exchange messages via send/receive
• Implementation of communication link
– physical (e.g., shared memory, hardware bus)
– logical (e.g., logical properties)
Silberschatz and Galvin ©19994.29
Implementation Questions
• 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?
Silberschatz and Galvin ©19994.30
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.
– 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.
Silberschatz and Galvin ©19994.31
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.
• Operations
– create a new mailbox
– send and receive messages through mailbox
– destroy a mailbox
Silberschatz and Galvin ©19994.32
Indirect Communication (Continued)
• 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.
Silberschatz and Galvin ©19994.33
Buffering
• Queue of messages attached to the link; implemented in one of
three ways.
1. Zero capacity – 0 messages
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.
Silberschatz and Galvin ©19994.34
Exception Conditions – Error
Recovery
• Process terminates
• Lost messages
• Scrambled Messages

More Related Content

What's hot

resource management
  resource management  resource management
resource managementAshish Kumar
 
Chapter 18 - Distributed Coordination
Chapter 18 - Distributed CoordinationChapter 18 - Distributed Coordination
Chapter 18 - Distributed CoordinationWayne Jones Jnr
 
RTAI - Earliest Deadline First
RTAI - Earliest Deadline FirstRTAI - Earliest Deadline First
RTAI - Earliest Deadline FirstStefano Bragaglia
 
process management
 process management process management
process managementAshish Kumar
 
Session 1 introduction concurrent programming
Session 1 introduction  concurrent programmingSession 1 introduction  concurrent programming
Session 1 introduction concurrent programmingEric Verhulst
 
DevoFlow - Scaling Flow Management for High-Performance Networks
DevoFlow - Scaling Flow Management for High-Performance NetworksDevoFlow - Scaling Flow Management for High-Performance Networks
DevoFlow - Scaling Flow Management for High-Performance NetworksJason TC HOU (侯宗成)
 
Leveraging Endpoint Flexibility in Data-Intensive Clusters
Leveraging Endpoint Flexibility in Data-Intensive ClustersLeveraging Endpoint Flexibility in Data-Intensive Clusters
Leveraging Endpoint Flexibility in Data-Intensive ClustersRan Ziv
 
Communication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed SystemsCommunication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed Systemsguest61205606
 

What's hot (19)

CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
resource management
  resource management  resource management
resource management
 
Chapter 18 - Distributed Coordination
Chapter 18 - Distributed CoordinationChapter 18 - Distributed Coordination
Chapter 18 - Distributed Coordination
 
RTAI - Earliest Deadline First
RTAI - Earliest Deadline FirstRTAI - Earliest Deadline First
RTAI - Earliest Deadline First
 
process management
 process management process management
process management
 
Session 1 introduction concurrent programming
Session 1 introduction  concurrent programmingSession 1 introduction  concurrent programming
Session 1 introduction concurrent programming
 
DevoFlow - Scaling Flow Management for High-Performance Networks
DevoFlow - Scaling Flow Management for High-Performance NetworksDevoFlow - Scaling Flow Management for High-Performance Networks
DevoFlow - Scaling Flow Management for High-Performance Networks
 
Resource management
Resource managementResource management
Resource management
 
Leveraging Endpoint Flexibility in Data-Intensive Clusters
Leveraging Endpoint Flexibility in Data-Intensive ClustersLeveraging Endpoint Flexibility in Data-Intensive Clusters
Leveraging Endpoint Flexibility in Data-Intensive Clusters
 
Task migration in os
Task migration in osTask migration in os
Task migration in os
 
Lecture 4 process cpu scheduling
Lecture 4   process cpu schedulingLecture 4   process cpu scheduling
Lecture 4 process cpu scheduling
 
Process Management-Process Migration
Process Management-Process MigrationProcess Management-Process Migration
Process Management-Process Migration
 
Os
OsOs
Os
 
Open MPI 2
Open MPI 2Open MPI 2
Open MPI 2
 
3 process management
3 process management3 process management
3 process management
 
Ch6 cpu scheduling
Ch6   cpu schedulingCh6   cpu scheduling
Ch6 cpu scheduling
 
Ds ppt imp.
Ds ppt imp.Ds ppt imp.
Ds ppt imp.
 
Communication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed SystemsCommunication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed Systems
 
Ch5 process synchronization
Ch5   process synchronizationCh5   process synchronization
Ch5 process synchronization
 

Similar to Ch4

Operating System-Ch4.processes
Operating System-Ch4.processesOperating System-Ch4.processes
Operating System-Ch4.processesSyaiful Ahdan
 
Architecting for the cloud elasticity security
Architecting for the cloud elasticity securityArchitecting for the cloud elasticity security
Architecting for the cloud elasticity securityLen Bass
 
Von Neumann Architecture microcontroller.pptx
Von Neumann Architecture microcontroller.pptxVon Neumann Architecture microcontroller.pptx
Von Neumann Architecture microcontroller.pptxSUNILNYATI2
 
Chapter -2 operating system presentation
Chapter -2 operating system presentationChapter -2 operating system presentation
Chapter -2 operating system presentationchnrketan
 
ch13 here is the ppt of this chapter included pictures
ch13 here is the ppt of this chapter included picturesch13 here is the ppt of this chapter included pictures
ch13 here is the ppt of this chapter included picturesPranjalRana4
 
Lecture- 2_Process Management.pdf
Lecture- 2_Process Management.pdfLecture- 2_Process Management.pdf
Lecture- 2_Process Management.pdfHarika Pudugosula
 
Operating System : Ch18 distributed coordination
Operating System : Ch18 distributed coordinationOperating System : Ch18 distributed coordination
Operating System : Ch18 distributed coordinationSyaiful Ahdan
 
Module2 MultiThreads.ppt
Module2 MultiThreads.pptModule2 MultiThreads.ppt
Module2 MultiThreads.pptshreesha16
 
Operating System : Ch16.distributed system structures
Operating System : Ch16.distributed system structuresOperating System : Ch16.distributed system structures
Operating System : Ch16.distributed system structuresSyaiful Ahdan
 
SYNCHRONIZATION IN MULTIPROCESSING
SYNCHRONIZATION IN MULTIPROCESSINGSYNCHRONIZATION IN MULTIPROCESSING
SYNCHRONIZATION IN MULTIPROCESSINGAparna Bhadran
 

Similar to Ch4 (20)

Ch3.processes
Ch3.processesCh3.processes
Ch3.processes
 
Operating System-Ch4.processes
Operating System-Ch4.processesOperating System-Ch4.processes
Operating System-Ch4.processes
 
운영체제론 Ch22
운영체제론 Ch22운영체제론 Ch22
운영체제론 Ch22
 
Ch1 introduction os
Ch1 introduction osCh1 introduction os
Ch1 introduction os
 
Architecting for the cloud elasticity security
Architecting for the cloud elasticity securityArchitecting for the cloud elasticity security
Architecting for the cloud elasticity security
 
운영체제론 Ch20
운영체제론 Ch20운영체제론 Ch20
운영체제론 Ch20
 
Ch3 processes
Ch3   processesCh3   processes
Ch3 processes
 
Von Neumann Architecture microcontroller.pptx
Von Neumann Architecture microcontroller.pptxVon Neumann Architecture microcontroller.pptx
Von Neumann Architecture microcontroller.pptx
 
Processes
ProcessesProcesses
Processes
 
Chapter -2 operating system presentation
Chapter -2 operating system presentationChapter -2 operating system presentation
Chapter -2 operating system presentation
 
Lect07
Lect07Lect07
Lect07
 
ch13 here is the ppt of this chapter included pictures
ch13 here is the ppt of this chapter included picturesch13 here is the ppt of this chapter included pictures
ch13 here is the ppt of this chapter included pictures
 
Lecture- 2_Process Management.pdf
Lecture- 2_Process Management.pdfLecture- 2_Process Management.pdf
Lecture- 2_Process Management.pdf
 
Unit - 5 Pipelining.pptx
Unit - 5 Pipelining.pptxUnit - 5 Pipelining.pptx
Unit - 5 Pipelining.pptx
 
Operating System : Ch18 distributed coordination
Operating System : Ch18 distributed coordinationOperating System : Ch18 distributed coordination
Operating System : Ch18 distributed coordination
 
Ch1
Ch1Ch1
Ch1
 
Module2 MultiThreads.ppt
Module2 MultiThreads.pptModule2 MultiThreads.ppt
Module2 MultiThreads.ppt
 
Lecture 5 inter process communication
Lecture 5 inter process communicationLecture 5 inter process communication
Lecture 5 inter process communication
 
Operating System : Ch16.distributed system structures
Operating System : Ch16.distributed system structuresOperating System : Ch16.distributed system structures
Operating System : Ch16.distributed system structures
 
SYNCHRONIZATION IN MULTIPROCESSING
SYNCHRONIZATION IN MULTIPROCESSINGSYNCHRONIZATION IN MULTIPROCESSING
SYNCHRONIZATION IN MULTIPROCESSING
 

Recently uploaded

(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 

Recently uploaded (20)

★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 

Ch4

  • 1. Silberschatz and Galvin ©19994.1 Module 4: Processes • Process Concept • Process Scheduling • Operation on Processes • Cooperating Processes • Interprocess Communication
  • 2. Silberschatz and Galvin ©19994.2 Process Concept • An operating system executes a variety of programs: – Batch system – jobs – Time-shared systems – user programs or tasks • Textbook uses the terms job and process almost interchangeably. • Process – a program in execution; process execution must progress in sequential fashion. • A process includes: – program counter – stack – data section
  • 3. Silberschatz and Galvin ©19994.3 Process State • As a process executes, it changes state – new: The process is being created. – running: Instructions are being executed. – waiting: The process is waiting for some event to occur. – ready: The process is waiting to be assigned to a process. – terminated: The process has finished execution.
  • 4. Silberschatz and Galvin ©19994.4 Diagram of Process State
  • 5. Silberschatz and Galvin ©19994.5 Process Control Block (PCB) Information associated with each process. • Process state • Program counter • CPU registers • CPU scheduling information • Memory-management information • Accounting information • I/O status information
  • 6. Silberschatz and Galvin ©19994.6 Process Control Block (PCB)
  • 7. Silberschatz and Galvin ©19994.7 CPU Switch From Process to Process
  • 8. Silberschatz and Galvin ©19994.8 Process Scheduling Queues • Job queue – set of all processes in the system. • Ready queue – set of all processes residing in main memory, ready and waiting to execute. • Device queues – set of processes waiting for an I/O device. • Process migration between the various queues.
  • 9. Silberschatz and Galvin ©19994.9 Ready Queue And Various I/O Device Queues
  • 10. Silberschatz and Galvin ©19994.10 Representation of Process Scheduling
  • 11. Silberschatz and Galvin ©19994.11 Schedulers • Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue. • Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU.
  • 12. Silberschatz and Galvin ©19994.12 Addition of Medium Term Scheduling
  • 13. Silberschatz and Galvin ©19994.13 Schedulers (Cont.) • Short-term scheduler is invoked very frequently (milliseconds) ⇒ (must be fast). • Long-term scheduler is invoked very infrequently (seconds, minutes) ⇒ (may be slow). • The long-term scheduler controls the degree of multiprogramming. • Processes can be described as either: – I/O-bound process – spends more time doing I/O than computations, many short CPU bursts. – CPU-bound process – spends more time doing computations; few very long CPU bursts.
  • 14. Silberschatz and Galvin ©19994.14 Context Switch • When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process. • Context-switch time is overhead; the system does no useful work while switching. • Time dependent on hardware support.
  • 15. Silberschatz and Galvin ©19994.15 Process Creation • Parent process creates children processes, which, in turn create other processes, forming a tree of processes. • Resource sharing – Parent and children share all resources. – Children share subset of parent’s resources. – Parent and child share no resources. • Execution – Parent and children execute concurrently. – Parent waits until children terminate.
  • 16. Silberschatz and Galvin ©19994.16 Process Creation (Cont.) • Address space – Child duplicate of parent. – Child has a program loaded into it. • UNIX examples – fork system call creates new process – execve system call used after a fork to replace the process’ memory space with a new program.
  • 17. Silberschatz and Galvin ©19994.17 A Tree of Processes On A Typical UNIX System
  • 18. Silberschatz and Galvin ©19994.18 Process Termination • Process executes last statement and asks the operating system to decide it (exit). – Output data from child to parent (via wait). – Process’ resources are deallocated by operating system. • Parent may terminate execution of children processes (abort). – Child has exceeded allocated resources. – Task assigned to child is no longer required. – Parent is exiting. Operating system does not allow child to continue if its parent terminates. Cascading termination.
  • 19. Silberschatz and Galvin ©19994.19 Cooperating Processes • Independent process cannot affect or be affected by the execution of another process. • Cooperating process can affect or be affected by the execution of another process • Advantages of process cooperation – Information sharing – Computation speed-up – Modularity – Convenience
  • 20. Silberschatz and Galvin ©19994.20 Producer-Consumer Problem • Paradigm for cooperating processes, producer process produces information that is consumed by a consumer process. – unbounded-buffer places no practical limit on the size of the buffer. – bounded-buffer assumes that there is a fixed buffer size.
  • 21. Silberschatz and Galvin ©19994.21 Bounded-Buffer – Shared-Memory Solution • Shared data var n; type item = … ; var buffer. array [0..n–1] of item; in, out: 0..n–1; • Producer process repeat … produce an item in nextp … while in+1 mod n = out do no-op; buffer [in] :=nextp; in :=in+1 mod n; until false;
  • 22. Silberschatz and Galvin ©19994.22 Bounded-Buffer (Cont.) • Consumer process repeat while in = out do no-op; nextc := buffer [out]; out := out+1 mod n; … consume the item in nextc … until false; • Solution is correct, but can only fill up n–1 buffer.
  • 23. Silberschatz and Galvin ©19994.23 Threads • A thread (or lightweight process) is a basic unit of CPU utilization; it consists of: – program counter – register set – stack space • A thread shares with its peer threads its: – code section – data section – operating-system resources collectively know as a task. • A traditional or heavyweight process is equal to a task with one thread
  • 24. Silberschatz and Galvin ©19994.24 Threads (Cont.) • In a multiple threaded task, while one server thread is blocked and waiting, a second thread in the same task can run. – Cooperation of multiple threads in same job confers higher throughput and improved performance. – Applications that require sharing a common buffer (i.e., producer-consumer) benefit from thread utilization. • Threads provide a mechanism that allows sequential processes to make blocking system calls while also achieving parallelism. • Kernel-supported threads (Mach and OS/2). • User-level threads; supported above the kernel, via a set of library calls at the user level (Project Andrew from CMU). • Hybrid approach implements both user-level and kernel- supported threads (Solaris 2).
  • 25. Silberschatz and Galvin ©19994.25 Multiple Threads within a Task
  • 26. Silberschatz and Galvin ©19994.26 Threads Support in Solaris 2 • Solaris 2 is a version of UNIX with support for threads at the kernel and user levels, symmetric multiprocessing, and real-time scheduling. • LWP – intermediate level between user-level threads and kernel-level threads. • Resource needs of thread types: – Kernel thread: small data structure and a stack; thread switching does not require changing memory access information – relatively fast. – LWP: PCB with register data, accounting and memory information,; switching between LWPs is relatively slow. – User-level thread: only ned stack and program counter; no kernel involvement means fast switching. Kernel only sees the LWPs that support user-level threads.
  • 27. Silberschatz and Galvin ©19994.27 Solaris 2 Threads
  • 28. Silberschatz and Galvin ©19994.28 Interprocess Communication (IPC) • 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) – message size fixed or variable – receive(message) • If P and Q wish to communicate, they need to: – establish a communication link between them – exchange messages via send/receive • Implementation of communication link – physical (e.g., shared memory, hardware bus) – logical (e.g., logical properties)
  • 29. Silberschatz and Galvin ©19994.29 Implementation Questions • 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?
  • 30. Silberschatz and Galvin ©19994.30 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. – 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.
  • 31. Silberschatz and Galvin ©19994.31 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. • Operations – create a new mailbox – send and receive messages through mailbox – destroy a mailbox
  • 32. Silberschatz and Galvin ©19994.32 Indirect Communication (Continued) • 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.
  • 33. Silberschatz and Galvin ©19994.33 Buffering • Queue of messages attached to the link; implemented in one of three ways. 1. Zero capacity – 0 messages 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.
  • 34. Silberschatz and Galvin ©19994.34 Exception Conditions – Error Recovery • Process terminates • Lost messages • Scrambled Messages