SlideShare a Scribd company logo
Chapter 6
1
CPU Scheduling
Chapter 6
2
Classification of Scheduling Activity
 Long-term: which process to admit
 Medium-term: which process to swap in or out
 Short-term: which ready process to execute next
3
Long-Term Scheduling
 Determines which programs are admitted
to the system for processing
 Controls the degree of multiprogramming
 If more processes are admitted
• less likely that all processes will be blocked
• better CPU usage
• each process has smaller fraction of the CPU
 The long term scheduler may attempt to
keep a mix of processor-bound and I/O-
bound processes
4
Medium-Term Scheduling
 Swapping decisions based on the need to
manage multiprogramming
• Allows the long-term scheduler to admit more
processes than actually fit in memory
• but too many processes can increase disk
activity (paging), so there is some “optimum”
level of multiprogramming.
 Done by memory management software
(chapter 8)
5
Short-Term Scheduling
 Determines which process is going to execute
next (also called CPU scheduling)
 the focus of this chapter..
 invoked on a event that may lead to choosing
another process for execution:
• clock interrupts
• I/O interrupts
• operating system calls and traps, including I/O
• signals
6
The CPU-I/O Cycle
Silberschatz, Galvin, and Gagne 1999
“CPU-bound”
processes require
more CPU time than
I/O time
“I/O-bound”
processes spend
most of their time
waiting for I/O.
7
Histogram of CPU-burst Times
Silberschatz, Galvin, and Gagne 1999
8
Our focus
 Uniprocessor Scheduling: scheduling a
single CPU among all the processes in the
system
 Key Criteria:
• Maximize CPU utilization
• Maximize throughput
• Minimize waiting times
• Minimize response time
• Minimize turnaround time
9
Criteria
 Maximize CPU utilization
• Efficiency
• Need to keep the CPU busy
 Minimize waiting times
• Time spent waiting in READY queue
• Each process should get a fair share of the
CPU
10
Criteria
 Maximize throughput
• Process completions per time unit
 Minimize response time
• From a user request to the first response
• I/O bound processes
 Minimize turnaround time
• CPU-bound process equivalent of response
time
• Elapsed time to complete a process
11
User vs. System Scheduling Criteria
User-oriented
 Turnaround Time (batch systems): Elapsed time
from the submission of a process to its
completion
 Response Time (interactive systems): Elapsed
time from the submission of a request to the first
response
System-oriented
 CPU utilization
 fairness
 throughput: processes completed per unit time
12
Two Components of Scheduling Policies
Selection function
 which process in the ready queue is selected next
for execution?
Decision mode
 at what times is the selection function exercised?
• Nonpreemptive
 A process in the running state runs until it blocks or
ends
• Preemptive
 Currently running process may be interrupted and
moved to the Ready state by the OS
 Prevents any one process from monopolizing the
CPU
13
Policy vs. Mechanism
 Important in scheduling and resource
allocation algorithms
 Policy
• What is to be done
 Mechanism
• How to do it
 Policy: All users equal access
 Mechanism: round robin scheduling
 Policy: Paid jobs get higher priority
 Mechanism: Preemptive scheduling
algorithm
14
A running example to discuss various
scheduling policies
Process
Arrival
Time
Burst
Time
1
2
3
4
5
0
2
4
6
8
3
6
4
5
2
15
First Come First Served (FCFS)
 Selection function: the process that has
been waiting the longest in the ready
queue (hence, FCFS, FIFO queue)
 Decision mode: nonpreemptive
• a process runs until it blocks itself (I/O or other)
16
FCFS Drawbacks
 Favors CPU-bound processes
• A process that does not perform any I/O will
monopolize the processor!
• I/O-bound processes have to wait until CPU-
bound process completes
• They may have to wait even when their I/Os
have completed
 poor device utilization
• We could reduce the average wait time by
giving more priority to I/O bound processes
17
Shortest Job First (SJF)
 Selection function: the process with the shortest
expected CPU burst time
 Decision mode: non-preemptive
 I/O bound processes will be picked first
 We need to estimate the expected CPU burst time
for each process: on the basis of past behavior.
Shortest job
First (SJF)
18
Estimating the Required CPU Burst
 Can average all past history equally
 But recent history of a process is more likely
to reflect future behavior
 A common technique for that is to use
exponential averaging
• S[n+1] = a T[n] + (1-a) S[n] ; 0 < a < 1
• Puts more weight on recent instances
whenever a > 1/n
19
Exponentially Decreasing Coefficients
20
Exponential Averaging
 Set S[1] = 0 to give new processes high priority.
 Exponential averaging tracks changes in process
behavior much faster than simple averaging.
21
Shortest Job First: Critique
 SJF implicitly incorporates priorities: shortest
jobs are given preference.
• Typically these are I/O bound jobs
 Longer processes can starve if there is a
steady supply of shorter processes
 Lack of preemption not suitable in a time
sharing environment
• CPU bound process gets lower priority
• But a process doing no I/O at all could
monopolize the CPU if it is the first one in the
system
22
Shortest Remaining Time (SRT) =
Preemptive SJF
 If a process arrives in the Ready queue
with estimated CPU burst less than
remaining time of the currently running
process, preempt.
 Prevents long jobs from dominating.
• But must keep track of remaining burst
times
 Better turnaround time than SJF
• Short jobs get immediate preference
23
 Selection function: same as FCFS
 Decision mode: Preemptive
• Maximum time slice (typically 10 - 100 ms)
enforced by timer interrupt
• running process is put at the tail of the ready
queue
Round-Robin
24
Time Quantum for Round Robin
 must be substantially larger than process switch time
 should be larger than the typical CPU burst
 If too large, degenerates to FCFS
 Too small, excessive context switches (overhead)
25
Fairness vs. Efficiency
 Each context switch has the OS using the
CPU instead of the user process
• give up CPU, save all info, reload w/ status of
incoming process
• Say 20 ms quantum length, 5 ms context switch
• Waste of resources
 20% of CPU time (5/20) for context switch
• If 500 ms quantum, better use of resources
 1% of CPU time (5/500) for context switch
 Bad if lots of users in system – interactive users
waiting for CPU
• Balance found depends on job mix
26
Round Robin: Critique
 Still favors CPU-bound processes
• An I/O bound process uses the CPU for a time less than
the time quantum and then is blocked waiting for I/O
• A CPU-bound process runs for its whole time slice and
goes back into the ready queue (in front of the blocked
processes)
 One solution: virtual round robin (VRR, not in
book…)
• When a I/O has completed, the blocked process is
moved to an auxiliary queue which gets preference over
the main ready queue
• A process dispatched from the auxiliary queue gets a
shorter time quantum (what is “left over” from its
quantum when it was last selected from the ready
queue)

More Related Content

Similar to May14ProcessScheduling.ppt

CPU scheduling in Operating System Explanation
CPU scheduling in Operating System ExplanationCPU scheduling in Operating System Explanation
CPU scheduling in Operating System Explanation
AnitaSofiaKeyser
 
LM10,11,12 - CPU SCHEDULING algorithms and its processes
LM10,11,12 - CPU SCHEDULING algorithms and its processesLM10,11,12 - CPU SCHEDULING algorithms and its processes
LM10,11,12 - CPU SCHEDULING algorithms and its processes
manideepakc
 
Process scheduling in Light weight weight and Heavy weight processes.
Process scheduling in Light weight weight and Heavy weight processes.Process scheduling in Light weight weight and Heavy weight processes.
Process scheduling in Light weight weight and Heavy weight processes.
Shreya Kumar
 
Scheduling Definition, objectives and types
Scheduling Definition, objectives and types Scheduling Definition, objectives and types
Scheduling Definition, objectives and types
Maitree Patel
 
Scheduling
SchedulingScheduling
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
Mukesh Chinta
 
CPU Scheduling.pptx
CPU Scheduling.pptxCPU Scheduling.pptx
CPU Scheduling.pptx
yashu23
 
Operating system 28 fundamental of scheduling
Operating system 28 fundamental of schedulingOperating system 28 fundamental of scheduling
Operating system 28 fundamental of scheduling
Vaibhav Khanna
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
KeyreSebre
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
Paurav Shah
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
Prakash Sir
 
In computing, scheduling is the action .
In computing, scheduling is the action .In computing, scheduling is the action .
In computing, scheduling is the action .
nathansel1
 
Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-scheduling
Nazir Ahmed
 
CPU Scheduling Part-III.pdf
CPU Scheduling Part-III.pdfCPU Scheduling Part-III.pdf
CPU Scheduling Part-III.pdf
Harika Pudugosula
 
Lecture- 2_Process Management.pdf
Lecture- 2_Process Management.pdfLecture- 2_Process Management.pdf
Lecture- 2_Process Management.pdf
Harika Pudugosula
 
Operating System Scheduling
Operating System SchedulingOperating System Scheduling
Operating System Scheduling
Vishnu Prasad
 
PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptx
DivyaKS18
 
Uniprocessor SchedulingCsci 430, Spring 2018Texas A&
Uniprocessor SchedulingCsci 430, Spring 2018Texas A&Uniprocessor SchedulingCsci 430, Spring 2018Texas A&
Uniprocessor SchedulingCsci 430, Spring 2018Texas A&
corbing9ttj
 
Osy ppt - Copy.pptx
Osy ppt - Copy.pptxOsy ppt - Copy.pptx
Osy ppt - Copy.pptx
NikhilShinde253288
 

Similar to May14ProcessScheduling.ppt (20)

CPU scheduling in Operating System Explanation
CPU scheduling in Operating System ExplanationCPU scheduling in Operating System Explanation
CPU scheduling in Operating System Explanation
 
LM10,11,12 - CPU SCHEDULING algorithms and its processes
LM10,11,12 - CPU SCHEDULING algorithms and its processesLM10,11,12 - CPU SCHEDULING algorithms and its processes
LM10,11,12 - CPU SCHEDULING algorithms and its processes
 
Process scheduling in Light weight weight and Heavy weight processes.
Process scheduling in Light weight weight and Heavy weight processes.Process scheduling in Light weight weight and Heavy weight processes.
Process scheduling in Light weight weight and Heavy weight processes.
 
Scheduling Definition, objectives and types
Scheduling Definition, objectives and types Scheduling Definition, objectives and types
Scheduling Definition, objectives and types
 
Scheduling
SchedulingScheduling
Scheduling
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
 
CPU Scheduling.pptx
CPU Scheduling.pptxCPU Scheduling.pptx
CPU Scheduling.pptx
 
Operating system 28 fundamental of scheduling
Operating system 28 fundamental of schedulingOperating system 28 fundamental of scheduling
Operating system 28 fundamental of scheduling
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
In computing, scheduling is the action .
In computing, scheduling is the action .In computing, scheduling is the action .
In computing, scheduling is the action .
 
Lect07
Lect07Lect07
Lect07
 
Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-scheduling
 
CPU Scheduling Part-III.pdf
CPU Scheduling Part-III.pdfCPU Scheduling Part-III.pdf
CPU Scheduling Part-III.pdf
 
Lecture- 2_Process Management.pdf
Lecture- 2_Process Management.pdfLecture- 2_Process Management.pdf
Lecture- 2_Process Management.pdf
 
Operating System Scheduling
Operating System SchedulingOperating System Scheduling
Operating System Scheduling
 
PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptx
 
Uniprocessor SchedulingCsci 430, Spring 2018Texas A&
Uniprocessor SchedulingCsci 430, Spring 2018Texas A&Uniprocessor SchedulingCsci 430, Spring 2018Texas A&
Uniprocessor SchedulingCsci 430, Spring 2018Texas A&
 
Osy ppt - Copy.pptx
Osy ppt - Copy.pptxOsy ppt - Copy.pptx
Osy ppt - Copy.pptx
 

More from ansariparveen06

discrete mathematics binary%20trees.pptx
discrete mathematics binary%20trees.pptxdiscrete mathematics binary%20trees.pptx
discrete mathematics binary%20trees.pptx
ansariparveen06
 
Introduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).pptIntroduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).ppt
ansariparveen06
 
Fundamentals of programming Arduino-Wk2.ppt
Fundamentals of programming Arduino-Wk2.pptFundamentals of programming Arduino-Wk2.ppt
Fundamentals of programming Arduino-Wk2.ppt
ansariparveen06
 
kmap.pptx
kmap.pptxkmap.pptx
kmap.pptx
ansariparveen06
 
Combinational_Logic_Circuit.pptx
Combinational_Logic_Circuit.pptxCombinational_Logic_Circuit.pptx
Combinational_Logic_Circuit.pptx
ansariparveen06
 
presentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptxpresentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptx
ansariparveen06
 
BCom-Sem2-Marketing-Digital-payment-Presentation.pptx
BCom-Sem2-Marketing-Digital-payment-Presentation.pptxBCom-Sem2-Marketing-Digital-payment-Presentation.pptx
BCom-Sem2-Marketing-Digital-payment-Presentation.pptx
ansariparveen06
 
dsa.ppt
dsa.pptdsa.ppt
11-IOManagement.ppt
11-IOManagement.ppt11-IOManagement.ppt
11-IOManagement.ppt
ansariparveen06
 
1-introduction-to-dart-programming.pptx
1-introduction-to-dart-programming.pptx1-introduction-to-dart-programming.pptx
1-introduction-to-dart-programming.pptx
ansariparveen06
 
green IT cooling.pptx
green IT cooling.pptxgreen IT cooling.pptx
green IT cooling.pptx
ansariparveen06
 
06-Deadlocks.ppt
06-Deadlocks.ppt06-Deadlocks.ppt
06-Deadlocks.ppt
ansariparveen06
 
chp9 green IT.pptx
chp9 green IT.pptxchp9 green IT.pptx
chp9 green IT.pptx
ansariparveen06
 
regex.ppt
regex.pptregex.ppt
regex.ppt
ansariparveen06
 
BOM.ppt
BOM.pptBOM.ppt
exception%20handlingcpp.pptx
exception%20handlingcpp.pptxexception%20handlingcpp.pptx
exception%20handlingcpp.pptx
ansariparveen06
 
C++InputOutput.pptx
C++InputOutput.pptxC++InputOutput.pptx
C++InputOutput.pptx
ansariparveen06
 

More from ansariparveen06 (20)

discrete mathematics binary%20trees.pptx
discrete mathematics binary%20trees.pptxdiscrete mathematics binary%20trees.pptx
discrete mathematics binary%20trees.pptx
 
Introduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).pptIntroduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).ppt
 
Fundamentals of programming Arduino-Wk2.ppt
Fundamentals of programming Arduino-Wk2.pptFundamentals of programming Arduino-Wk2.ppt
Fundamentals of programming Arduino-Wk2.ppt
 
pscheduling.ppt
pscheduling.pptpscheduling.ppt
pscheduling.ppt
 
kmap.pptx
kmap.pptxkmap.pptx
kmap.pptx
 
Combinational_Logic_Circuit.pptx
Combinational_Logic_Circuit.pptxCombinational_Logic_Circuit.pptx
Combinational_Logic_Circuit.pptx
 
presentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptxpresentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptx
 
BCom-Sem2-Marketing-Digital-payment-Presentation.pptx
BCom-Sem2-Marketing-Digital-payment-Presentation.pptxBCom-Sem2-Marketing-Digital-payment-Presentation.pptx
BCom-Sem2-Marketing-Digital-payment-Presentation.pptx
 
dsa.ppt
dsa.pptdsa.ppt
dsa.ppt
 
11-IOManagement.ppt
11-IOManagement.ppt11-IOManagement.ppt
11-IOManagement.ppt
 
1-introduction-to-dart-programming.pptx
1-introduction-to-dart-programming.pptx1-introduction-to-dart-programming.pptx
1-introduction-to-dart-programming.pptx
 
CHAP4.pptx
CHAP4.pptxCHAP4.pptx
CHAP4.pptx
 
green IT cooling.pptx
green IT cooling.pptxgreen IT cooling.pptx
green IT cooling.pptx
 
06-Deadlocks.ppt
06-Deadlocks.ppt06-Deadlocks.ppt
06-Deadlocks.ppt
 
chp9 green IT.pptx
chp9 green IT.pptxchp9 green IT.pptx
chp9 green IT.pptx
 
regex.ppt
regex.pptregex.ppt
regex.ppt
 
BOM.ppt
BOM.pptBOM.ppt
BOM.ppt
 
Cooling.pptx
Cooling.pptxCooling.pptx
Cooling.pptx
 
exception%20handlingcpp.pptx
exception%20handlingcpp.pptxexception%20handlingcpp.pptx
exception%20handlingcpp.pptx
 
C++InputOutput.pptx
C++InputOutput.pptxC++InputOutput.pptx
C++InputOutput.pptx
 

Recently uploaded

Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 

Recently uploaded (20)

Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 

May14ProcessScheduling.ppt

  • 2. 2 Classification of Scheduling Activity  Long-term: which process to admit  Medium-term: which process to swap in or out  Short-term: which ready process to execute next
  • 3. 3 Long-Term Scheduling  Determines which programs are admitted to the system for processing  Controls the degree of multiprogramming  If more processes are admitted • less likely that all processes will be blocked • better CPU usage • each process has smaller fraction of the CPU  The long term scheduler may attempt to keep a mix of processor-bound and I/O- bound processes
  • 4. 4 Medium-Term Scheduling  Swapping decisions based on the need to manage multiprogramming • Allows the long-term scheduler to admit more processes than actually fit in memory • but too many processes can increase disk activity (paging), so there is some “optimum” level of multiprogramming.  Done by memory management software (chapter 8)
  • 5. 5 Short-Term Scheduling  Determines which process is going to execute next (also called CPU scheduling)  the focus of this chapter..  invoked on a event that may lead to choosing another process for execution: • clock interrupts • I/O interrupts • operating system calls and traps, including I/O • signals
  • 6. 6 The CPU-I/O Cycle Silberschatz, Galvin, and Gagne 1999 “CPU-bound” processes require more CPU time than I/O time “I/O-bound” processes spend most of their time waiting for I/O.
  • 7. 7 Histogram of CPU-burst Times Silberschatz, Galvin, and Gagne 1999
  • 8. 8 Our focus  Uniprocessor Scheduling: scheduling a single CPU among all the processes in the system  Key Criteria: • Maximize CPU utilization • Maximize throughput • Minimize waiting times • Minimize response time • Minimize turnaround time
  • 9. 9 Criteria  Maximize CPU utilization • Efficiency • Need to keep the CPU busy  Minimize waiting times • Time spent waiting in READY queue • Each process should get a fair share of the CPU
  • 10. 10 Criteria  Maximize throughput • Process completions per time unit  Minimize response time • From a user request to the first response • I/O bound processes  Minimize turnaround time • CPU-bound process equivalent of response time • Elapsed time to complete a process
  • 11. 11 User vs. System Scheduling Criteria User-oriented  Turnaround Time (batch systems): Elapsed time from the submission of a process to its completion  Response Time (interactive systems): Elapsed time from the submission of a request to the first response System-oriented  CPU utilization  fairness  throughput: processes completed per unit time
  • 12. 12 Two Components of Scheduling Policies Selection function  which process in the ready queue is selected next for execution? Decision mode  at what times is the selection function exercised? • Nonpreemptive  A process in the running state runs until it blocks or ends • Preemptive  Currently running process may be interrupted and moved to the Ready state by the OS  Prevents any one process from monopolizing the CPU
  • 13. 13 Policy vs. Mechanism  Important in scheduling and resource allocation algorithms  Policy • What is to be done  Mechanism • How to do it  Policy: All users equal access  Mechanism: round robin scheduling  Policy: Paid jobs get higher priority  Mechanism: Preemptive scheduling algorithm
  • 14. 14 A running example to discuss various scheduling policies Process Arrival Time Burst Time 1 2 3 4 5 0 2 4 6 8 3 6 4 5 2
  • 15. 15 First Come First Served (FCFS)  Selection function: the process that has been waiting the longest in the ready queue (hence, FCFS, FIFO queue)  Decision mode: nonpreemptive • a process runs until it blocks itself (I/O or other)
  • 16. 16 FCFS Drawbacks  Favors CPU-bound processes • A process that does not perform any I/O will monopolize the processor! • I/O-bound processes have to wait until CPU- bound process completes • They may have to wait even when their I/Os have completed  poor device utilization • We could reduce the average wait time by giving more priority to I/O bound processes
  • 17. 17 Shortest Job First (SJF)  Selection function: the process with the shortest expected CPU burst time  Decision mode: non-preemptive  I/O bound processes will be picked first  We need to estimate the expected CPU burst time for each process: on the basis of past behavior. Shortest job First (SJF)
  • 18. 18 Estimating the Required CPU Burst  Can average all past history equally  But recent history of a process is more likely to reflect future behavior  A common technique for that is to use exponential averaging • S[n+1] = a T[n] + (1-a) S[n] ; 0 < a < 1 • Puts more weight on recent instances whenever a > 1/n
  • 20. 20 Exponential Averaging  Set S[1] = 0 to give new processes high priority.  Exponential averaging tracks changes in process behavior much faster than simple averaging.
  • 21. 21 Shortest Job First: Critique  SJF implicitly incorporates priorities: shortest jobs are given preference. • Typically these are I/O bound jobs  Longer processes can starve if there is a steady supply of shorter processes  Lack of preemption not suitable in a time sharing environment • CPU bound process gets lower priority • But a process doing no I/O at all could monopolize the CPU if it is the first one in the system
  • 22. 22 Shortest Remaining Time (SRT) = Preemptive SJF  If a process arrives in the Ready queue with estimated CPU burst less than remaining time of the currently running process, preempt.  Prevents long jobs from dominating. • But must keep track of remaining burst times  Better turnaround time than SJF • Short jobs get immediate preference
  • 23. 23  Selection function: same as FCFS  Decision mode: Preemptive • Maximum time slice (typically 10 - 100 ms) enforced by timer interrupt • running process is put at the tail of the ready queue Round-Robin
  • 24. 24 Time Quantum for Round Robin  must be substantially larger than process switch time  should be larger than the typical CPU burst  If too large, degenerates to FCFS  Too small, excessive context switches (overhead)
  • 25. 25 Fairness vs. Efficiency  Each context switch has the OS using the CPU instead of the user process • give up CPU, save all info, reload w/ status of incoming process • Say 20 ms quantum length, 5 ms context switch • Waste of resources  20% of CPU time (5/20) for context switch • If 500 ms quantum, better use of resources  1% of CPU time (5/500) for context switch  Bad if lots of users in system – interactive users waiting for CPU • Balance found depends on job mix
  • 26. 26 Round Robin: Critique  Still favors CPU-bound processes • An I/O bound process uses the CPU for a time less than the time quantum and then is blocked waiting for I/O • A CPU-bound process runs for its whole time slice and goes back into the ready queue (in front of the blocked processes)  One solution: virtual round robin (VRR, not in book…) • When a I/O has completed, the blocked process is moved to an auxiliary queue which gets preference over the main ready queue • A process dispatched from the auxiliary queue gets a shorter time quantum (what is “left over” from its quantum when it was last selected from the ready queue)