SlideShare a Scribd company logo
5: CPU-Scheduling 1
Jerry Breecher
OPERATING SYSTEMS
SCHEDULING
5: CPU-Scheduling 2
What Is In This Chapter?
• This chapter is about how to get a process attached to a processor.
• It centers around efficient algorithms that perform well.
• The design of a scheduler is concerned with making sure all users get
their fair share of the resources.
CPU Scheduling
5: CPU-Scheduling 3
What Is In This Chapter?
• Basic Concepts
• Scheduling Criteria
• Scheduling Algorithms
• Multiple-Processor Scheduling
• Real-Time Scheduling
• Thread Scheduling
• Operating Systems Examples
• Java Thread Scheduling
• Algorithm Evaluation
CPU Scheduling
5: CPU-Scheduling 4
CPU SCHEDULING Scheduling
Concepts
Multiprogramming A number of programs can be in
memory at the same time. Allows
overlap of CPU and I/O.
Jobs (batch) are programs that run
without user interaction.
User (time shared) are programs that
may have user interaction.
Process is the common name for both.
CPU - I/O burst cycle Characterizes process execution,
which alternates, between CPU and
I/O activity. CPU times are
generally much shorter than I/O
times.
Preemptive Scheduling An interrupt causes currently
running process to give up the CPU
and be replaced by another process.
5: CPU-Scheduling 5
CPU SCHEDULING The Scheduler
Selects from among the processes in memory that are ready to execute, and
allocates the CPU to one of them
CPU scheduling decisions may take place when a process:
1. Switches from running to waiting state
2. Switches from running to ready state
3. Switches from waiting to ready
4. Terminates
Scheduling under 1 and 4 is nonpreemptive
All other scheduling is preemptive
5: CPU-Scheduling 6
CPU SCHEDULING The Dispatcher
Dispatcher module gives control of the CPU to the process selected by the short-
term scheduler; this involves:
switching context
switching to user mode
jumping to the proper location in the user program to restart that program
Dispatch latency – time it takes for the dispatcher to stop one process and start
another running
5: CPU-Scheduling 7
Note usage of the words DEVICE, SYSTEM, REQUEST, JOB.
UTILIZATION The fraction of time a device is in use. ( ratio of in-use time / total
observation time )
THROUGHPUT The number of job completions in a period of time. (jobs / second )
SERVICE TIME The time required by a device to handle a request. (seconds)
QUEUEING TIME Time on a queue waiting for service from the device. (seconds)
RESIDENCE TIME The time spent by a request at a device.
RESIDENCE TIME = SERVICE TIME + QUEUEING TIME.
RESPONSE TIME Time used by a system to respond to a User Job. ( seconds )
THINK TIME The time spent by the user of an interactive system to figure out the next
request. (seconds)
The goal is to optimize both the average and the amount of variation. (but beware the ogre
predictability.)
CPU SCHEDULING
Criteria For
Performance
Evaluation
5: CPU-Scheduling 8
Most Processes Don’t Use Up Their Scheduling Quantum!
CPU SCHEDULING
Scheduling
Behavior
5: CPU-Scheduling 9
FIRST-COME, FIRST SERVED:
• ( FCFS) same as FIFO
• Simple, fair, but poor performance. Average queueing time may be long.
• What are the average queueing and residence times for this scenario?
• How do average queueing and residence times depend on ordering of these
processes in the queue?
CPU SCHEDULING Scheduling
Algorithms
5: CPU-Scheduling 10
EXAMPLE DATA:
Process Arrival Service
Time Time
1 0 8
2 1 4
3 2 9
4 3 5
0 8 12 21 26
P1 P2 P3 P4
FCFS
Average wait = ( (8-0) + (12-1) + (21-2) + (26-3) )/4 = 61/4 = 15.25
CPU SCHEDULING Scheduling
Algorithms
Residence Time
at the CPU
5: CPU-Scheduling 11
SHORTEST JOB FIRST:
• Optimal for minimizing queueing time, but impossible to implement.
Tries to predict the process to schedule based on previous history.
• Predicting the time the process will use on its next schedule:
t( n+1 ) = w * t( n ) + ( 1 - w ) * T( n )
Here: t(n+1) is time of next burst.
t(n) is time of current burst.
T(n) is average of all previous bursts .
W is a weighting factor emphasizing current or previous bursts.
CPU SCHEDULING Scheduling
Algorithms
5: CPU-Scheduling 12
PREEMPTIVE ALGORITHMS:
• Yank the CPU away from the currently executing process when a higher
priority process is ready.
• Can be applied to both Shortest Job First or to Priority scheduling.
• Avoids "hogging" of the CPU
• On time sharing machines, this type of scheme is required because the
CPU must be protected from a run-away low priority process.
• Give short jobs a higher priority – perceived response time is thus
better.
• What are average queueing and residence times? Compare with FCFS.
CPU SCHEDULING Scheduling
Algorithms
5: CPU-Scheduling 13
EXAMPLE DATA:
Process Arrival Service
Time Time
1 0 8
2 1 4
3 2 9
4 3 5
0 5 10 17 26
P2 P4 P1 P3
Preemptive Shortest Job First
Average wait = ( (5-1) + (10-3) + (17-0) + (26-2) )/4 = 52/4 = 13.0
P1
1
CPU SCHEDULING Scheduling
Algorithms
5: CPU-Scheduling 14
PRIORITY BASED SCHEDULING:
• Assign each process a priority. Schedule highest priority first. All processes within
same priority are FCFS.
• Priority may be determined by user or by some default mechanism. The system
may determine the priority based on memory requirements, time limits, or other
resource usage.
• Starvation occurs if a low priority process never runs. Solution: build aging into a
variable priority.
• Delicate balance between giving favorable response for interactive jobs, but not
starving batch jobs.
CPU SCHEDULING Scheduling
Algorithms
5: CPU-Scheduling 15
ROUND ROBIN:
• Use a timer to cause an interrupt after a predetermined time. Preempts if task
exceeds it’s quantum.
• Train of events
Dispatch
Time slice occurs OR process suspends on event
Put process on some queue and dispatch next
• Use numbers in last example to find queueing and residence times. (Use
quantum = 4 sec.)
• Definitions:
– Context Switch Changing the processor from running one task
(or process) to another. Implies changing memory.
– Processor Sharing Use of a small quantum such that each process
runs frequently at speed 1/n.
– Reschedule latency How long it takes from when a process requests
to run, until it finally gets control of the CPU.
CPU SCHEDULING Scheduling
Algorithms
5: CPU-Scheduling 16
ROUND ROBIN:
• Choosing a time quantum
– Too short - inordinate fraction of the time is spent in context switches.
– Too long - reschedule latency is too great. If many processes want
the CPU, then it's a long time before a particular process can get the
CPU. This then acts like FCFS.
– Adjust so most processes won't use their slice. As processors have
become faster, this is less of an issue.
CPU SCHEDULING Scheduling
Algorithms
5: CPU-Scheduling 17
EXAMPLE DATA:
Process Arrival Service
Time Time
1 0 8
2 1 4
3 2 9
4 3 5
0 8 12 16 26
P2 P3 P4 P1
Round Robin, quantum = 4, no priority-based preemption
Average wait = ( (20-0) + (8-1) + (26-2) + (25-3) )/4 = 74/4 = 18.5
P1
4
P3 P4
20 24 25
P3
CPU SCHEDULING Scheduling
Algorithms
Note:
Example violates rules for
quantum size since most
processes don’t finish in one
quantum.
5: CPU-Scheduling 18
MULTI-LEVEL QUEUES:
• Each queue has its scheduling algorithm.
• Then some other algorithm (perhaps priority based) arbitrates between queues.
• Can use feedback to move between queues
• Method is complex but flexible.
• For example, could separate system processes, interactive, batch, favored, unfavored
processes
CPU SCHEDULING Scheduling
Algorithms
5: CPU-Scheduling 19
Here’s how the priorities are used in Windows
CPU SCHEDULING Using Priorities
5: CPU-Scheduling 20
MULTIPLE PROCESSOR SCHEDULING:
• Different rules for homogeneous or heterogeneous processors.
• Load sharing in the distribution of work, such that all processors have an
equal amount to do.
• Each processor can schedule from a common ready queue ( equal
machines ) OR can use a master slave arrangement.
Real Time Scheduling:
• Hard real-time systems – required to complete a critical task within a
guaranteed amount of time.
• Soft real-time computing – requires that critical processes receive priority
over less fortunate ones.
CPU SCHEDULING Scheduling
Algorithms
5: CPU-Scheduling 21
Two algorithms: time-sharing and real-time
• Time-sharing
– Prioritized credit-based – process with most credits is scheduled next
– Credit subtracted when timer interrupt occurs
– When credit = 0, another process chosen
– When all processes have credit = 0, recrediting occurs
• Based on factors including priority and history
• Real-time
– Soft real-time
– Posix.1b compliant – two classes
• FCFS and RR
• Highest priority process runs first
CPU SCHEDULING Linux Scheduling
5: CPU-Scheduling 22
How do we decide which algorithm is best for a particular environment?
• Deterministic modeling – takes a particular predetermined workload and defines
the performance of each algorithm for that workload.
• Queueing models.
CPU SCHEDULING Algorithm Evaluation
5: CPU-Scheduling 23
We’ve looked at a number of different scheduling algorithms.
Which one works the best is application dependent.
General purpose OS will use priority based, round robin, preemptive
Real Time OS will use priority, no preemption.
CPU SCHEDULING
WRAPUP
Ad

More Related Content

What's hot (19)

OS Process and Thread Concepts
OS Process and Thread ConceptsOS Process and Thread Concepts
OS Process and Thread Concepts
sgpraju
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
Deepika Balichwal
 
Srt algorithm
Srt algorithmSrt algorithm
Srt algorithm
dianne10
 
scheduling
schedulingscheduling
scheduling
Gaurav Shinde
 
Operating Systems 1 (10/12) - Scheduling
Operating Systems 1 (10/12) - SchedulingOperating Systems 1 (10/12) - Scheduling
Operating Systems 1 (10/12) - Scheduling
Peter Tröger
 
Windows process-scheduling
Windows process-schedulingWindows process-scheduling
Windows process-scheduling
Talha Shaikh
 
Windows process scheduling presentation
Windows process scheduling presentationWindows process scheduling presentation
Windows process scheduling presentation
Talha Shaikh
 
Processor management
Processor managementProcessor management
Processor management
dev3993
 
MULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULINGMULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULING
garishma bhatia
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
Karthick Sekar
 
Window scheduling algorithm
Window scheduling algorithmWindow scheduling algorithm
Window scheduling algorithm
Binal Parekh
 
Real-Time Scheduling
Real-Time SchedulingReal-Time Scheduling
Real-Time Scheduling
sathish sak
 
scheduling algorithm
scheduling algorithmscheduling algorithm
scheduling algorithm
nitish sandhawar
 
Process management
Process managementProcess management
Process management
Birju Tank
 
Ch6 CPU Scheduling galvin
Ch6 CPU Scheduling galvinCh6 CPU Scheduling galvin
Ch6 CPU Scheduling galvin
Shubham Singh
 
Lecture 2 process
Lecture 2   processLecture 2   process
Lecture 2 process
Kumbirai Junior Muzavazi
 
cpu scheduling.pdf
cpu scheduling.pdfcpu scheduling.pdf
cpu scheduling.pdf
MuralidharaV3
 
Process management in os
Process management in osProcess management in os
Process management in os
Miong Lazaro
 
Cpu scheduling pre final formatting
Cpu scheduling pre final formattingCpu scheduling pre final formatting
Cpu scheduling pre final formatting
marangburu42
 
OS Process and Thread Concepts
OS Process and Thread ConceptsOS Process and Thread Concepts
OS Process and Thread Concepts
sgpraju
 
Srt algorithm
Srt algorithmSrt algorithm
Srt algorithm
dianne10
 
Operating Systems 1 (10/12) - Scheduling
Operating Systems 1 (10/12) - SchedulingOperating Systems 1 (10/12) - Scheduling
Operating Systems 1 (10/12) - Scheduling
Peter Tröger
 
Windows process-scheduling
Windows process-schedulingWindows process-scheduling
Windows process-scheduling
Talha Shaikh
 
Windows process scheduling presentation
Windows process scheduling presentationWindows process scheduling presentation
Windows process scheduling presentation
Talha Shaikh
 
Processor management
Processor managementProcessor management
Processor management
dev3993
 
MULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULINGMULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULING
garishma bhatia
 
Window scheduling algorithm
Window scheduling algorithmWindow scheduling algorithm
Window scheduling algorithm
Binal Parekh
 
Real-Time Scheduling
Real-Time SchedulingReal-Time Scheduling
Real-Time Scheduling
sathish sak
 
Process management
Process managementProcess management
Process management
Birju Tank
 
Ch6 CPU Scheduling galvin
Ch6 CPU Scheduling galvinCh6 CPU Scheduling galvin
Ch6 CPU Scheduling galvin
Shubham Singh
 
Process management in os
Process management in osProcess management in os
Process management in os
Miong Lazaro
 
Cpu scheduling pre final formatting
Cpu scheduling pre final formattingCpu scheduling pre final formatting
Cpu scheduling pre final formatting
marangburu42
 

Viewers also liked (8)

Pharos hand out presentation nl 05 2013
Pharos hand out presentation nl 05 2013Pharos hand out presentation nl 05 2013
Pharos hand out presentation nl 05 2013
David Vermeulen
 
20121205 presentatie roel willems webanalyse, conversie en cookie trends 2013
20121205 presentatie roel willems   webanalyse, conversie en cookie trends 201320121205 presentatie roel willems   webanalyse, conversie en cookie trends 2013
20121205 presentatie roel willems webanalyse, conversie en cookie trends 2013
OrangeValley
 
Ihtoc60 jenniferhillhousesarahcross.onceuponateentimehandouts
Ihtoc60 jenniferhillhousesarahcross.onceuponateentimehandoutsIhtoc60 jenniferhillhousesarahcross.onceuponateentimehandouts
Ihtoc60 jenniferhillhousesarahcross.onceuponateentimehandouts
Onlineconference
 
Presentacion perritolandia
Presentacion perritolandiaPresentacion perritolandia
Presentacion perritolandia
Inesita0721
 
Stay Up To Date on the Latest Happenings in the Boardroom: Recommended Summer...
Stay Up To Date on the Latest Happenings in the Boardroom: Recommended Summer...Stay Up To Date on the Latest Happenings in the Boardroom: Recommended Summer...
Stay Up To Date on the Latest Happenings in the Boardroom: Recommended Summer...
Stanford GSB Corporate Governance Research Initiative
 
10 Tips for WeChat
10 Tips for WeChat10 Tips for WeChat
10 Tips for WeChat
Chris Baker
 
Benefits of drinking water
Benefits of drinking waterBenefits of drinking water
Benefits of drinking water
Eason Chan
 
20 Ideas for your Website Homepage Content
20 Ideas for your Website Homepage Content20 Ideas for your Website Homepage Content
20 Ideas for your Website Homepage Content
Barry Feldman
 
Pharos hand out presentation nl 05 2013
Pharos hand out presentation nl 05 2013Pharos hand out presentation nl 05 2013
Pharos hand out presentation nl 05 2013
David Vermeulen
 
20121205 presentatie roel willems webanalyse, conversie en cookie trends 2013
20121205 presentatie roel willems   webanalyse, conversie en cookie trends 201320121205 presentatie roel willems   webanalyse, conversie en cookie trends 2013
20121205 presentatie roel willems webanalyse, conversie en cookie trends 2013
OrangeValley
 
Ihtoc60 jenniferhillhousesarahcross.onceuponateentimehandouts
Ihtoc60 jenniferhillhousesarahcross.onceuponateentimehandoutsIhtoc60 jenniferhillhousesarahcross.onceuponateentimehandouts
Ihtoc60 jenniferhillhousesarahcross.onceuponateentimehandouts
Onlineconference
 
Presentacion perritolandia
Presentacion perritolandiaPresentacion perritolandia
Presentacion perritolandia
Inesita0721
 
10 Tips for WeChat
10 Tips for WeChat10 Tips for WeChat
10 Tips for WeChat
Chris Baker
 
Benefits of drinking water
Benefits of drinking waterBenefits of drinking water
Benefits of drinking water
Eason Chan
 
20 Ideas for your Website Homepage Content
20 Ideas for your Website Homepage Content20 Ideas for your Website Homepage Content
20 Ideas for your Website Homepage Content
Barry Feldman
 
Ad

Similar to Section05 scheduling (20)

Scheduling.ppt with operating system slides
Scheduling.ppt with operating system slidesScheduling.ppt with operating system slides
Scheduling.ppt with operating system slides
lovepreet33653
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
amadayshwan
 
CPU scheduling in Operating System Explanation
CPU scheduling in Operating System ExplanationCPU scheduling in Operating System Explanation
CPU scheduling in Operating System Explanation
AnitaSofiaKeyser
 
MODULE 2 for the cpu shcheduling and.ppt
MODULE 2 for the cpu shcheduling and.pptMODULE 2 for the cpu shcheduling and.ppt
MODULE 2 for the cpu shcheduling and.ppt
adityaraj822269
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
KeyreSebre
 
cpu scheduling by shivam singh
cpu scheduling by shivam singhcpu scheduling by shivam singh
cpu scheduling by shivam singh
shivam71291
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
mohsinalilarik1
 
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
 
ch_scheduling (1).ppt
ch_scheduling (1).pptch_scheduling (1).ppt
ch_scheduling (1).ppt
Farhanahmad540205
 
Lecture 3 CPU scheduling_2.pdflllllllllll
Lecture 3 CPU scheduling_2.pdflllllllllllLecture 3 CPU scheduling_2.pdflllllllllll
Lecture 3 CPU scheduling_2.pdflllllllllll
MohamedPalastine
 
Lecture 3 CPU scheduling.pdfvgukgiolphpiphjp
Lecture 3 CPU scheduling.pdfvgukgiolphpiphjpLecture 3 CPU scheduling.pdfvgukgiolphpiphjp
Lecture 3 CPU scheduling.pdfvgukgiolphpiphjp
MohamedPalastine
 
May14ProcessScheduling.ppt
May14ProcessScheduling.pptMay14ProcessScheduling.ppt
May14ProcessScheduling.ppt
ansariparveen06
 
pscheduling.ppt
pscheduling.pptpscheduling.ppt
pscheduling.ppt
ansariparveen06
 
UNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxUNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptx
ansariparveen06
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
Paurav Shah
 
operating system (1).pdf
operating system (1).pdfoperating system (1).pdf
operating system (1).pdf
AliyanAbbas1
 
3Chapter Three- CPU Scheduling this is the best.pptx
3Chapter Three- CPU Scheduling this is the best.pptx3Chapter Three- CPU Scheduling this is the best.pptx
3Chapter Three- CPU Scheduling this is the best.pptx
habtegebeyawu
 
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
 
DISEÑO DE MEMORIA EN SISTEMAS DE INFORMACION DIGITALES
DISEÑO DE MEMORIA EN SISTEMAS DE INFORMACION DIGITALESDISEÑO DE MEMORIA EN SISTEMAS DE INFORMACION DIGITALES
DISEÑO DE MEMORIA EN SISTEMAS DE INFORMACION DIGITALES
2021207019est
 
topic cpu scheduling in operating system.pptx
topic cpu scheduling in operating system.pptxtopic cpu scheduling in operating system.pptx
topic cpu scheduling in operating system.pptx
iotsaprofessor
 
Scheduling.ppt with operating system slides
Scheduling.ppt with operating system slidesScheduling.ppt with operating system slides
Scheduling.ppt with operating system slides
lovepreet33653
 
CPU scheduling in Operating System Explanation
CPU scheduling in Operating System ExplanationCPU scheduling in Operating System Explanation
CPU scheduling in Operating System Explanation
AnitaSofiaKeyser
 
MODULE 2 for the cpu shcheduling and.ppt
MODULE 2 for the cpu shcheduling and.pptMODULE 2 for the cpu shcheduling and.ppt
MODULE 2 for the cpu shcheduling and.ppt
adityaraj822269
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
KeyreSebre
 
cpu scheduling by shivam singh
cpu scheduling by shivam singhcpu scheduling by shivam singh
cpu scheduling by shivam singh
shivam71291
 
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
 
Lecture 3 CPU scheduling_2.pdflllllllllll
Lecture 3 CPU scheduling_2.pdflllllllllllLecture 3 CPU scheduling_2.pdflllllllllll
Lecture 3 CPU scheduling_2.pdflllllllllll
MohamedPalastine
 
Lecture 3 CPU scheduling.pdfvgukgiolphpiphjp
Lecture 3 CPU scheduling.pdfvgukgiolphpiphjpLecture 3 CPU scheduling.pdfvgukgiolphpiphjp
Lecture 3 CPU scheduling.pdfvgukgiolphpiphjp
MohamedPalastine
 
May14ProcessScheduling.ppt
May14ProcessScheduling.pptMay14ProcessScheduling.ppt
May14ProcessScheduling.ppt
ansariparveen06
 
UNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxUNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptx
ansariparveen06
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
Paurav Shah
 
operating system (1).pdf
operating system (1).pdfoperating system (1).pdf
operating system (1).pdf
AliyanAbbas1
 
3Chapter Three- CPU Scheduling this is the best.pptx
3Chapter Three- CPU Scheduling this is the best.pptx3Chapter Three- CPU Scheduling this is the best.pptx
3Chapter Three- CPU Scheduling this is the best.pptx
habtegebeyawu
 
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
 
DISEÑO DE MEMORIA EN SISTEMAS DE INFORMACION DIGITALES
DISEÑO DE MEMORIA EN SISTEMAS DE INFORMACION DIGITALESDISEÑO DE MEMORIA EN SISTEMAS DE INFORMACION DIGITALES
DISEÑO DE MEMORIA EN SISTEMAS DE INFORMACION DIGITALES
2021207019est
 
topic cpu scheduling in operating system.pptx
topic cpu scheduling in operating system.pptxtopic cpu scheduling in operating system.pptx
topic cpu scheduling in operating system.pptx
iotsaprofessor
 
Ad

Recently uploaded (20)

Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 

Section05 scheduling

  • 1. 5: CPU-Scheduling 1 Jerry Breecher OPERATING SYSTEMS SCHEDULING
  • 2. 5: CPU-Scheduling 2 What Is In This Chapter? • This chapter is about how to get a process attached to a processor. • It centers around efficient algorithms that perform well. • The design of a scheduler is concerned with making sure all users get their fair share of the resources. CPU Scheduling
  • 3. 5: CPU-Scheduling 3 What Is In This Chapter? • Basic Concepts • Scheduling Criteria • Scheduling Algorithms • Multiple-Processor Scheduling • Real-Time Scheduling • Thread Scheduling • Operating Systems Examples • Java Thread Scheduling • Algorithm Evaluation CPU Scheduling
  • 4. 5: CPU-Scheduling 4 CPU SCHEDULING Scheduling Concepts Multiprogramming A number of programs can be in memory at the same time. Allows overlap of CPU and I/O. Jobs (batch) are programs that run without user interaction. User (time shared) are programs that may have user interaction. Process is the common name for both. CPU - I/O burst cycle Characterizes process execution, which alternates, between CPU and I/O activity. CPU times are generally much shorter than I/O times. Preemptive Scheduling An interrupt causes currently running process to give up the CPU and be replaced by another process.
  • 5. 5: CPU-Scheduling 5 CPU SCHEDULING The Scheduler Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them CPU scheduling decisions may take place when a process: 1. Switches from running to waiting state 2. Switches from running to ready state 3. Switches from waiting to ready 4. Terminates Scheduling under 1 and 4 is nonpreemptive All other scheduling is preemptive
  • 6. 5: CPU-Scheduling 6 CPU SCHEDULING The Dispatcher Dispatcher module gives control of the CPU to the process selected by the short- term scheduler; this involves: switching context switching to user mode jumping to the proper location in the user program to restart that program Dispatch latency – time it takes for the dispatcher to stop one process and start another running
  • 7. 5: CPU-Scheduling 7 Note usage of the words DEVICE, SYSTEM, REQUEST, JOB. UTILIZATION The fraction of time a device is in use. ( ratio of in-use time / total observation time ) THROUGHPUT The number of job completions in a period of time. (jobs / second ) SERVICE TIME The time required by a device to handle a request. (seconds) QUEUEING TIME Time on a queue waiting for service from the device. (seconds) RESIDENCE TIME The time spent by a request at a device. RESIDENCE TIME = SERVICE TIME + QUEUEING TIME. RESPONSE TIME Time used by a system to respond to a User Job. ( seconds ) THINK TIME The time spent by the user of an interactive system to figure out the next request. (seconds) The goal is to optimize both the average and the amount of variation. (but beware the ogre predictability.) CPU SCHEDULING Criteria For Performance Evaluation
  • 8. 5: CPU-Scheduling 8 Most Processes Don’t Use Up Their Scheduling Quantum! CPU SCHEDULING Scheduling Behavior
  • 9. 5: CPU-Scheduling 9 FIRST-COME, FIRST SERVED: • ( FCFS) same as FIFO • Simple, fair, but poor performance. Average queueing time may be long. • What are the average queueing and residence times for this scenario? • How do average queueing and residence times depend on ordering of these processes in the queue? CPU SCHEDULING Scheduling Algorithms
  • 10. 5: CPU-Scheduling 10 EXAMPLE DATA: Process Arrival Service Time Time 1 0 8 2 1 4 3 2 9 4 3 5 0 8 12 21 26 P1 P2 P3 P4 FCFS Average wait = ( (8-0) + (12-1) + (21-2) + (26-3) )/4 = 61/4 = 15.25 CPU SCHEDULING Scheduling Algorithms Residence Time at the CPU
  • 11. 5: CPU-Scheduling 11 SHORTEST JOB FIRST: • Optimal for minimizing queueing time, but impossible to implement. Tries to predict the process to schedule based on previous history. • Predicting the time the process will use on its next schedule: t( n+1 ) = w * t( n ) + ( 1 - w ) * T( n ) Here: t(n+1) is time of next burst. t(n) is time of current burst. T(n) is average of all previous bursts . W is a weighting factor emphasizing current or previous bursts. CPU SCHEDULING Scheduling Algorithms
  • 12. 5: CPU-Scheduling 12 PREEMPTIVE ALGORITHMS: • Yank the CPU away from the currently executing process when a higher priority process is ready. • Can be applied to both Shortest Job First or to Priority scheduling. • Avoids "hogging" of the CPU • On time sharing machines, this type of scheme is required because the CPU must be protected from a run-away low priority process. • Give short jobs a higher priority – perceived response time is thus better. • What are average queueing and residence times? Compare with FCFS. CPU SCHEDULING Scheduling Algorithms
  • 13. 5: CPU-Scheduling 13 EXAMPLE DATA: Process Arrival Service Time Time 1 0 8 2 1 4 3 2 9 4 3 5 0 5 10 17 26 P2 P4 P1 P3 Preemptive Shortest Job First Average wait = ( (5-1) + (10-3) + (17-0) + (26-2) )/4 = 52/4 = 13.0 P1 1 CPU SCHEDULING Scheduling Algorithms
  • 14. 5: CPU-Scheduling 14 PRIORITY BASED SCHEDULING: • Assign each process a priority. Schedule highest priority first. All processes within same priority are FCFS. • Priority may be determined by user or by some default mechanism. The system may determine the priority based on memory requirements, time limits, or other resource usage. • Starvation occurs if a low priority process never runs. Solution: build aging into a variable priority. • Delicate balance between giving favorable response for interactive jobs, but not starving batch jobs. CPU SCHEDULING Scheduling Algorithms
  • 15. 5: CPU-Scheduling 15 ROUND ROBIN: • Use a timer to cause an interrupt after a predetermined time. Preempts if task exceeds it’s quantum. • Train of events Dispatch Time slice occurs OR process suspends on event Put process on some queue and dispatch next • Use numbers in last example to find queueing and residence times. (Use quantum = 4 sec.) • Definitions: – Context Switch Changing the processor from running one task (or process) to another. Implies changing memory. – Processor Sharing Use of a small quantum such that each process runs frequently at speed 1/n. – Reschedule latency How long it takes from when a process requests to run, until it finally gets control of the CPU. CPU SCHEDULING Scheduling Algorithms
  • 16. 5: CPU-Scheduling 16 ROUND ROBIN: • Choosing a time quantum – Too short - inordinate fraction of the time is spent in context switches. – Too long - reschedule latency is too great. If many processes want the CPU, then it's a long time before a particular process can get the CPU. This then acts like FCFS. – Adjust so most processes won't use their slice. As processors have become faster, this is less of an issue. CPU SCHEDULING Scheduling Algorithms
  • 17. 5: CPU-Scheduling 17 EXAMPLE DATA: Process Arrival Service Time Time 1 0 8 2 1 4 3 2 9 4 3 5 0 8 12 16 26 P2 P3 P4 P1 Round Robin, quantum = 4, no priority-based preemption Average wait = ( (20-0) + (8-1) + (26-2) + (25-3) )/4 = 74/4 = 18.5 P1 4 P3 P4 20 24 25 P3 CPU SCHEDULING Scheduling Algorithms Note: Example violates rules for quantum size since most processes don’t finish in one quantum.
  • 18. 5: CPU-Scheduling 18 MULTI-LEVEL QUEUES: • Each queue has its scheduling algorithm. • Then some other algorithm (perhaps priority based) arbitrates between queues. • Can use feedback to move between queues • Method is complex but flexible. • For example, could separate system processes, interactive, batch, favored, unfavored processes CPU SCHEDULING Scheduling Algorithms
  • 19. 5: CPU-Scheduling 19 Here’s how the priorities are used in Windows CPU SCHEDULING Using Priorities
  • 20. 5: CPU-Scheduling 20 MULTIPLE PROCESSOR SCHEDULING: • Different rules for homogeneous or heterogeneous processors. • Load sharing in the distribution of work, such that all processors have an equal amount to do. • Each processor can schedule from a common ready queue ( equal machines ) OR can use a master slave arrangement. Real Time Scheduling: • Hard real-time systems – required to complete a critical task within a guaranteed amount of time. • Soft real-time computing – requires that critical processes receive priority over less fortunate ones. CPU SCHEDULING Scheduling Algorithms
  • 21. 5: CPU-Scheduling 21 Two algorithms: time-sharing and real-time • Time-sharing – Prioritized credit-based – process with most credits is scheduled next – Credit subtracted when timer interrupt occurs – When credit = 0, another process chosen – When all processes have credit = 0, recrediting occurs • Based on factors including priority and history • Real-time – Soft real-time – Posix.1b compliant – two classes • FCFS and RR • Highest priority process runs first CPU SCHEDULING Linux Scheduling
  • 22. 5: CPU-Scheduling 22 How do we decide which algorithm is best for a particular environment? • Deterministic modeling – takes a particular predetermined workload and defines the performance of each algorithm for that workload. • Queueing models. CPU SCHEDULING Algorithm Evaluation
  • 23. 5: CPU-Scheduling 23 We’ve looked at a number of different scheduling algorithms. Which one works the best is application dependent. General purpose OS will use priority based, round robin, preemptive Real Time OS will use priority, no preemption. CPU SCHEDULING WRAPUP