SlideShare a Scribd company logo
Silberschatz, Galvin and Gagne ©20026.1
Chapter 6: CPU Scheduling
Basic Concepts
Scheduling Criteria
Scheduling Algorithms
Multiple-Processor Scheduling
Real-Time Scheduling
Algorithm Evaluation
Silberschatz, Galvin and Gagne ©20026.2
Basic Concepts
Maximum CPU utilization obtained with
multiprogramming
CPU–I/O Burst Cycle – Process execution consists of a
cycle of CPU execution and I/O wait.
CPU burst distribution
Silberschatz, Galvin and Gagne ©20026.3
Alternating Sequence of CPU And I/O
Bursts
Silberschatz, Galvin and Gagne ©20026.4
Histogram of CPU-burst Times
Silberschatz, Galvin and Gagne ©20026.5
CPU 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.
Silberschatz, Galvin and Gagne ©20026.6
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.
Silberschatz, Galvin and Gagne ©20026.7
Scheduling Criteria
CPU utilization – keep the CPU as busy as possible
Throughput – # of processes that complete their
execution per time unit
Turnaround time – amount of time to execute a particular
process
Waiting time – amount of time a process has been waiting
in the ready queue
Response time – amount of time it takes from when a
request was submitted until the first response is
produced, not output (for time-sharing environment)
Silberschatz, Galvin and Gagne ©20026.8
Optimization Criteria
Max CPU utilization
Max throughput
Min turnaround time
Min waiting time
Min response time
Silberschatz, Galvin and Gagne ©20026.9
First-Come, First-Served (FCFS)
Scheduling
Process Burst Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P1 , P2 , P3
The Gantt Chart for the schedule is:
Waiting time for P1 = 0; P2 = 24; P3 = 27
Average waiting time: (0 + 24 + 27)/3 = 17
P1 P2 P3
24 27 300
Silberschatz, Galvin and Gagne ©20026.10
FCFS Scheduling (Cont.)
Suppose that the processes arrive in the order
P2 , P3 , P1 .
The Gantt chart for the schedule is:
Waiting time for P1 = 6;P2 = 0; P3 = 3
Average waiting time: (6 + 0 + 3)/3 = 3
Much better than previous case.
Convoy effect short process behind long process
P1P3P2
63 300
Silberschatz, Galvin and Gagne ©20026.11
Shortest-Job-First (SJR)
Scheduling
Associate with each process the length of its next CPU
burst. Use these lengths to schedule the process with the
shortest time.
Two schemes:
nonpreemptive – once CPU given to the process it cannot
be preempted until completes its CPU burst.
preemptive – if a new process arrives with CPU burst length
less than remaining time of current executing process,
preempt. This scheme is know as the
Shortest-Remaining-Time-First (SRTF).
SJF is optimal – gives minimum average waiting time for
a given set of processes.
Silberschatz, Galvin and Gagne ©20026.12
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
SJF (non-preemptive)
Average waiting time = (0 + 6 + 3 + 7)/4 - 4
Example of Non-Preemptive SJF
P1 P3 P2
73 160
P4
8 12
Silberschatz, Galvin and Gagne ©20026.13
Example of Preemptive SJF
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
SJF (preemptive)
Average waiting time = (9 + 1 + 0 +2)/4 - 3
P1 P3P2
42 110
P4
5 7
P2 P1
16
Silberschatz, Galvin and Gagne ©20026.14
Determining Length of Next CPU
Burst
Can only estimate the length.
Can be done by using the length of previous CPU bursts,
using exponential averaging.
:Define4.
10,3.
burstCPUnexttheforvaluepredicted2.
burstCPUoflenghtactual1.
≤≤
=
=
+
αα
τ 1n
th
n nt
( ) .t nnn ταατ −+== 11
Silberschatz, Galvin and Gagne ©20026.15
Prediction of the Length of the Next CPU
Burst
Silberschatz, Galvin and Gagne ©20026.16
Examples of Exponential
Averaging
α =0
τn+1 = τn
Recent history does not count.
α =1
τn+1 = tn
Only the actual last CPU burst counts.
If we expand the formula, we get:
τn+1 = α tn+(1 - α) α tn -1 + …
+(1 - α )j
α tn -1 + …
+(1 - α )n=1
tn τ0
Since both α and (1 - α) are less than or equal to 1, each
successive term has less weight than its predecessor.
Silberschatz, Galvin and Gagne ©20026.17
Priority Scheduling
A priority number (integer) is associated with each
process
The CPU is allocated to the process with the highest
priority (smallest integer ≡ highest priority).
Preemptive
nonpreemptive
SJF is a priority scheduling where priority is the predicted
next CPU burst time.
Problem ≡ Starvation – low priority processes may never
execute.
Solution ≡ Aging – as time progresses increase the
priority of the process.
Silberschatz, Galvin and Gagne ©20026.18
Round Robin (RR)
Each process gets a small unit of CPU time (time
quantum), usually 10-100 milliseconds. After this time
has elapsed, the process is preempted and added to the
end of the ready queue.
If there are n processes in the ready queue and the time
quantum is q, then each process gets 1/n of the CPU time
in chunks of at most q time units at once. No process
waits more than (n-1)q time units.
Performance
q large ⇒ FIFO
q small ⇒ q must be large with respect to context switch,
otherwise overhead is too high.
Silberschatz, Galvin and Gagne ©20026.19
Example of RR with Time Quantum =
20
Process Burst Time
P1 53
P2 17
P3 68
P4 24
The Gantt chart is:
Typically, higher average turnaround than SJF, but better
response.
P1 P2 P3 P4 P1 P3 P4 P1 P3 P3
0 20 37 57 77 97 117 121 134 154 162
Silberschatz, Galvin and Gagne ©20026.20
Time Quantum and Context Switch
Time
Silberschatz, Galvin and Gagne ©20026.21
Turnaround Time Varies With The Time
Quantum
Silberschatz, Galvin and Gagne ©20026.22
Multilevel Queue
Ready queue is partitioned into separate queues:
foreground (interactive)
background (batch)
Each queue has its own scheduling algorithm,
foreground – RR
background – FCFS
Scheduling must be done between the queues.
Fixed priority scheduling; (i.e., serve all from foreground
then from background). Possibility of starvation.
Time slice – each queue gets a certain amount of CPU time
which it can schedule amongst its processes; i.e., 80% to
foreground in RR
20% to background in FCFS
Silberschatz, Galvin and Gagne ©20026.23
Multilevel Queue Scheduling
Silberschatz, Galvin and Gagne ©20026.24
Multilevel Feedback Queue
A process can move between the various queues; aging
can be implemented this way.
Multilevel-feedback-queue scheduler defined by the
following parameters:
number of queues
scheduling algorithms for each queue
method used to determine when to upgrade a process
method used to determine when to demote a process
method used to determine which queue a process will enter
when that process needs service
Silberschatz, Galvin and Gagne ©20026.25
Example of Multilevel Feedback
Queue
Three queues:
Q0 – time quantum 8 milliseconds
Q1 – time quantum 16 milliseconds
Q2 – FCFS
Scheduling
A new job enters queue Q0 which is served FCFS. When it
gains CPU, job receives 8 milliseconds. If it does not finish
in 8 milliseconds, job is moved to queue Q1.
At Q1 job is again served FCFS and receives 16 additional
milliseconds. If it still does not complete, it is preempted
and moved to queue Q2.
Silberschatz, Galvin and Gagne ©20026.26
Multilevel Feedback Queues
Silberschatz, Galvin and Gagne ©20026.27
Multiple-Processor Scheduling
CPU scheduling more complex when multiple CPUs are
available.
Homogeneous processors within a multiprocessor.
Load sharing
Asymmetric multiprocessing – only one processor
accesses the system data structures, alleviating the need
for data sharing.
Silberschatz, Galvin and Gagne ©20026.28
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.
Silberschatz, Galvin and Gagne ©20026.29
Dispatch Latency
Silberschatz, Galvin and Gagne ©20026.30
Algorithm Evaluation
Deterministic modeling – takes a particular predetermined
workload and defines the performance of each algorithm
for that workload.
Queueing models
Implementation
Silberschatz, Galvin and Gagne ©20026.31
Evaluation of CPU Schedulers by
Simulation
Silberschatz, Galvin and Gagne ©20026.32
Solaris 2 Scheduling
Silberschatz, Galvin and Gagne ©20026.33
Windows 2000 Priorities

More Related Content

What's hot

Operating system concepts
Operating system conceptsOperating system concepts
Operating system concepts
Starlee Lathong
 
Process management in linux
Process management in linuxProcess management in linux
Process management in linux
Mazenetsolution
 
Windows process-scheduling
Windows process-schedulingWindows process-scheduling
Windows process-scheduling
Talha Shaikh
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
NEERAJ BAGHEL
 
Thread scheduling in Operating Systems
Thread scheduling in Operating SystemsThread scheduling in Operating Systems
Thread scheduling in Operating SystemsNitish Gulati
 
cpu scheduling
cpu schedulingcpu scheduling
cpu scheduling
hashim102
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
Suvendu Kumar Dash
 
MULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULINGMULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULING
garishma bhatia
 
Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)
ritu98
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memory
sgpraju
 
Os services
Os servicesOs services
Os services
anilkumar_mca
 
Computer system architecture
Computer system architectureComputer system architecture
Computer system architectureKumar
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
Chankey Pathak
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
vampugani
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
Riya Choudhary
 
Round robin scheduling
Round robin schedulingRound robin scheduling
Round robin scheduling
Raghav S
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual Memory
Wayne Jones Jnr
 

What's hot (20)

Operating system concepts
Operating system conceptsOperating system concepts
Operating system concepts
 
Process management in linux
Process management in linuxProcess management in linux
Process management in linux
 
Windows process-scheduling
Windows process-schedulingWindows process-scheduling
Windows process-scheduling
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
 
Thread scheduling in Operating Systems
Thread scheduling in Operating SystemsThread scheduling in Operating Systems
Thread scheduling in Operating Systems
 
cpu scheduling
cpu schedulingcpu scheduling
cpu scheduling
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
MULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULINGMULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULING
 
Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memory
 
Os services
Os servicesOs services
Os services
 
Computer system architecture
Computer system architectureComputer system architecture
Computer system architecture
 
Memory management
Memory managementMemory management
Memory management
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Process scheduling linux
Process scheduling linuxProcess scheduling linux
Process scheduling linux
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
Round robin scheduling
Round robin schedulingRound robin scheduling
Round robin scheduling
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual Memory
 

Similar to Ch6 CPU Scheduling galvin

5.CPU Scheduling
5.CPU Scheduling5.CPU Scheduling
5.CPU Scheduling
Senthil Kanth
 
Galvin-operating System(Ch6)
Galvin-operating System(Ch6)Galvin-operating System(Ch6)
Galvin-operating System(Ch6)dsuyal1
 
ch6.ppt
ch6.pptch6.ppt
cloud computing chapter one in computer science
cloud computing chapter one in computer sciencecloud computing chapter one in computer science
cloud computing chapter one in computer science
TSha7
 
6 cpu scheduling
6 cpu scheduling6 cpu scheduling
6 cpu scheduling
BaliThorat1
 
ch6_CPU Scheduling.ppt
ch6_CPU Scheduling.pptch6_CPU Scheduling.ppt
ch6_CPU Scheduling.ppt
ridham29
 
ch6.ppt
ch6.pptch6.ppt
ch6.ppt
Umesh Hengaju
 
ch6.ppt
ch6.pptch6.ppt
ch6.ppt
HeshmatMati
 
scheduling.ppt
scheduling.pptscheduling.ppt
scheduling.ppt
John100878
 
ch6.ppt
ch6.pptch6.ppt
ch6.ppt
Sami Mughal
 
ch6.ppt
ch6.pptch6.ppt
ch6 (2).ppt operating system by williamm
ch6 (2).ppt operating system by williammch6 (2).ppt operating system by williamm
ch6 (2).ppt operating system by williamm
sidrayounas2004
 
Various CPU Scheduling Algorithms in OS.ppt
Various CPU Scheduling Algorithms in OS.pptVarious CPU Scheduling Algorithms in OS.ppt
Various CPU Scheduling Algorithms in OS.ppt
taricvilla
 
ch5_EN_CPUSched_2022.pdf
ch5_EN_CPUSched_2022.pdfch5_EN_CPUSched_2022.pdf
ch5_EN_CPUSched_2022.pdf
CuracaoJTR
 
cpu scheduling.ppt
cpu scheduling.pptcpu scheduling.ppt
cpu scheduling.ppt
byuvashreeitITDept
 
CPU scheduling ppt file
CPU scheduling ppt fileCPU scheduling ppt file
CPU scheduling ppt file
Dwight Sabio
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
SyedTalhaBukhari2
 
Cpu scheduling (1)
Cpu scheduling (1)Cpu scheduling (1)
Cpu scheduling (1)
Ayush Oberai
 
Ch5 cpu-scheduling
Ch5 cpu-schedulingCh5 cpu-scheduling
Ch5 cpu-scheduling
Ankit Dubey
 
Operating System - CPU Scheduling Introduction
Operating System - CPU Scheduling IntroductionOperating System - CPU Scheduling Introduction
Operating System - CPU Scheduling Introduction
JimmyWilson26
 

Similar to Ch6 CPU Scheduling galvin (20)

5.CPU Scheduling
5.CPU Scheduling5.CPU Scheduling
5.CPU Scheduling
 
Galvin-operating System(Ch6)
Galvin-operating System(Ch6)Galvin-operating System(Ch6)
Galvin-operating System(Ch6)
 
ch6.ppt
ch6.pptch6.ppt
ch6.ppt
 
cloud computing chapter one in computer science
cloud computing chapter one in computer sciencecloud computing chapter one in computer science
cloud computing chapter one in computer science
 
6 cpu scheduling
6 cpu scheduling6 cpu scheduling
6 cpu scheduling
 
ch6_CPU Scheduling.ppt
ch6_CPU Scheduling.pptch6_CPU Scheduling.ppt
ch6_CPU Scheduling.ppt
 
ch6.ppt
ch6.pptch6.ppt
ch6.ppt
 
ch6.ppt
ch6.pptch6.ppt
ch6.ppt
 
scheduling.ppt
scheduling.pptscheduling.ppt
scheduling.ppt
 
ch6.ppt
ch6.pptch6.ppt
ch6.ppt
 
ch6.ppt
ch6.pptch6.ppt
ch6.ppt
 
ch6 (2).ppt operating system by williamm
ch6 (2).ppt operating system by williammch6 (2).ppt operating system by williamm
ch6 (2).ppt operating system by williamm
 
Various CPU Scheduling Algorithms in OS.ppt
Various CPU Scheduling Algorithms in OS.pptVarious CPU Scheduling Algorithms in OS.ppt
Various CPU Scheduling Algorithms in OS.ppt
 
ch5_EN_CPUSched_2022.pdf
ch5_EN_CPUSched_2022.pdfch5_EN_CPUSched_2022.pdf
ch5_EN_CPUSched_2022.pdf
 
cpu scheduling.ppt
cpu scheduling.pptcpu scheduling.ppt
cpu scheduling.ppt
 
CPU scheduling ppt file
CPU scheduling ppt fileCPU scheduling ppt file
CPU scheduling ppt file
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Cpu scheduling (1)
Cpu scheduling (1)Cpu scheduling (1)
Cpu scheduling (1)
 
Ch5 cpu-scheduling
Ch5 cpu-schedulingCh5 cpu-scheduling
Ch5 cpu-scheduling
 
Operating System - CPU Scheduling Introduction
Operating System - CPU Scheduling IntroductionOperating System - CPU Scheduling Introduction
Operating System - CPU Scheduling Introduction
 

More from Shubham Singh

Certificate of Completion
Certificate of CompletionCertificate of Completion
Certificate of Completion
Shubham Singh
 
Certificate of Completion
Certificate of CompletionCertificate of Completion
Certificate of Completion
Shubham Singh
 
Gmail google for education - certificate of achievement
Gmail   google for education - certificate of achievementGmail   google for education - certificate of achievement
Gmail google for education - certificate of achievement
Shubham Singh
 
Transmission media 2
Transmission media 2Transmission media 2
Transmission media 2
Shubham Singh
 
Transmission media ppt
Transmission media pptTransmission media ppt
Transmission media ppt
Shubham Singh
 
Wifi ppt
Wifi pptWifi ppt
Wifi ppt
Shubham Singh
 
Microprocessor 8085 complete
Microprocessor 8085 completeMicroprocessor 8085 complete
Microprocessor 8085 complete
Shubham Singh
 
Ch9 Virtual Memory
Ch9 Virtual MemoryCh9 Virtual Memory
Ch9 Virtual Memory
Shubham Singh
 
Ch7 Process Synchronization galvin
Ch7 Process Synchronization galvinCh7 Process Synchronization galvin
Ch7 Process Synchronization galvin
Shubham Singh
 
Ch5 threads galvin
Ch5 threads  galvinCh5 threads  galvin
Ch5 threads galvin
Shubham Singh
 
Interrupt 8085
Interrupt 8085Interrupt 8085
Interrupt 8085
Shubham Singh
 
Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085
Shubham Singh
 
Chapter 1 microprocessor introduction
Chapter 1 microprocessor introductionChapter 1 microprocessor introduction
Chapter 1 microprocessor introduction
Shubham Singh
 

More from Shubham Singh (13)

Certificate of Completion
Certificate of CompletionCertificate of Completion
Certificate of Completion
 
Certificate of Completion
Certificate of CompletionCertificate of Completion
Certificate of Completion
 
Gmail google for education - certificate of achievement
Gmail   google for education - certificate of achievementGmail   google for education - certificate of achievement
Gmail google for education - certificate of achievement
 
Transmission media 2
Transmission media 2Transmission media 2
Transmission media 2
 
Transmission media ppt
Transmission media pptTransmission media ppt
Transmission media ppt
 
Wifi ppt
Wifi pptWifi ppt
Wifi ppt
 
Microprocessor 8085 complete
Microprocessor 8085 completeMicroprocessor 8085 complete
Microprocessor 8085 complete
 
Ch9 Virtual Memory
Ch9 Virtual MemoryCh9 Virtual Memory
Ch9 Virtual Memory
 
Ch7 Process Synchronization galvin
Ch7 Process Synchronization galvinCh7 Process Synchronization galvin
Ch7 Process Synchronization galvin
 
Ch5 threads galvin
Ch5 threads  galvinCh5 threads  galvin
Ch5 threads galvin
 
Interrupt 8085
Interrupt 8085Interrupt 8085
Interrupt 8085
 
Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085
 
Chapter 1 microprocessor introduction
Chapter 1 microprocessor introductionChapter 1 microprocessor introduction
Chapter 1 microprocessor introduction
 

Recently uploaded

AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 

Recently uploaded (20)

AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 

Ch6 CPU Scheduling galvin

  • 1. Silberschatz, Galvin and Gagne ©20026.1 Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation
  • 2. Silberschatz, Galvin and Gagne ©20026.2 Basic Concepts Maximum CPU utilization obtained with multiprogramming CPU–I/O Burst Cycle – Process execution consists of a cycle of CPU execution and I/O wait. CPU burst distribution
  • 3. Silberschatz, Galvin and Gagne ©20026.3 Alternating Sequence of CPU And I/O Bursts
  • 4. Silberschatz, Galvin and Gagne ©20026.4 Histogram of CPU-burst Times
  • 5. Silberschatz, Galvin and Gagne ©20026.5 CPU 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. Silberschatz, Galvin and Gagne ©20026.6 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. Silberschatz, Galvin and Gagne ©20026.7 Scheduling Criteria CPU utilization – keep the CPU as busy as possible Throughput – # of processes that complete their execution per time unit Turnaround time – amount of time to execute a particular process Waiting time – amount of time a process has been waiting in the ready queue Response time – amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)
  • 8. Silberschatz, Galvin and Gagne ©20026.8 Optimization Criteria Max CPU utilization Max throughput Min turnaround time Min waiting time Min response time
  • 9. Silberschatz, Galvin and Gagne ©20026.9 First-Come, First-Served (FCFS) Scheduling Process Burst Time P1 24 P2 3 P3 3 Suppose that the processes arrive in the order: P1 , P2 , P3 The Gantt Chart for the schedule is: Waiting time for P1 = 0; P2 = 24; P3 = 27 Average waiting time: (0 + 24 + 27)/3 = 17 P1 P2 P3 24 27 300
  • 10. Silberschatz, Galvin and Gagne ©20026.10 FCFS Scheduling (Cont.) Suppose that the processes arrive in the order P2 , P3 , P1 . The Gantt chart for the schedule is: Waiting time for P1 = 6;P2 = 0; P3 = 3 Average waiting time: (6 + 0 + 3)/3 = 3 Much better than previous case. Convoy effect short process behind long process P1P3P2 63 300
  • 11. Silberschatz, Galvin and Gagne ©20026.11 Shortest-Job-First (SJR) Scheduling Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time. Two schemes: nonpreemptive – once CPU given to the process it cannot be preempted until completes its CPU burst. preemptive – if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is know as the Shortest-Remaining-Time-First (SRTF). SJF is optimal – gives minimum average waiting time for a given set of processes.
  • 12. Silberschatz, Galvin and Gagne ©20026.12 Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 SJF (non-preemptive) Average waiting time = (0 + 6 + 3 + 7)/4 - 4 Example of Non-Preemptive SJF P1 P3 P2 73 160 P4 8 12
  • 13. Silberschatz, Galvin and Gagne ©20026.13 Example of Preemptive SJF Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 SJF (preemptive) Average waiting time = (9 + 1 + 0 +2)/4 - 3 P1 P3P2 42 110 P4 5 7 P2 P1 16
  • 14. Silberschatz, Galvin and Gagne ©20026.14 Determining Length of Next CPU Burst Can only estimate the length. Can be done by using the length of previous CPU bursts, using exponential averaging. :Define4. 10,3. burstCPUnexttheforvaluepredicted2. burstCPUoflenghtactual1. ≤≤ = = + αα τ 1n th n nt ( ) .t nnn ταατ −+== 11
  • 15. Silberschatz, Galvin and Gagne ©20026.15 Prediction of the Length of the Next CPU Burst
  • 16. Silberschatz, Galvin and Gagne ©20026.16 Examples of Exponential Averaging α =0 τn+1 = τn Recent history does not count. α =1 τn+1 = tn Only the actual last CPU burst counts. If we expand the formula, we get: τn+1 = α tn+(1 - α) α tn -1 + … +(1 - α )j α tn -1 + … +(1 - α )n=1 tn τ0 Since both α and (1 - α) are less than or equal to 1, each successive term has less weight than its predecessor.
  • 17. Silberschatz, Galvin and Gagne ©20026.17 Priority Scheduling A priority number (integer) is associated with each process The CPU is allocated to the process with the highest priority (smallest integer ≡ highest priority). Preemptive nonpreemptive SJF is a priority scheduling where priority is the predicted next CPU burst time. Problem ≡ Starvation – low priority processes may never execute. Solution ≡ Aging – as time progresses increase the priority of the process.
  • 18. Silberschatz, Galvin and Gagne ©20026.18 Round Robin (RR) Each process gets a small unit of CPU time (time quantum), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time units. Performance q large ⇒ FIFO q small ⇒ q must be large with respect to context switch, otherwise overhead is too high.
  • 19. Silberschatz, Galvin and Gagne ©20026.19 Example of RR with Time Quantum = 20 Process Burst Time P1 53 P2 17 P3 68 P4 24 The Gantt chart is: Typically, higher average turnaround than SJF, but better response. P1 P2 P3 P4 P1 P3 P4 P1 P3 P3 0 20 37 57 77 97 117 121 134 154 162
  • 20. Silberschatz, Galvin and Gagne ©20026.20 Time Quantum and Context Switch Time
  • 21. Silberschatz, Galvin and Gagne ©20026.21 Turnaround Time Varies With The Time Quantum
  • 22. Silberschatz, Galvin and Gagne ©20026.22 Multilevel Queue Ready queue is partitioned into separate queues: foreground (interactive) background (batch) Each queue has its own scheduling algorithm, foreground – RR background – FCFS Scheduling must be done between the queues. Fixed priority scheduling; (i.e., serve all from foreground then from background). Possibility of starvation. Time slice – each queue gets a certain amount of CPU time which it can schedule amongst its processes; i.e., 80% to foreground in RR 20% to background in FCFS
  • 23. Silberschatz, Galvin and Gagne ©20026.23 Multilevel Queue Scheduling
  • 24. Silberschatz, Galvin and Gagne ©20026.24 Multilevel Feedback Queue A process can move between the various queues; aging can be implemented this way. Multilevel-feedback-queue scheduler defined by the following parameters: number of queues scheduling algorithms for each queue method used to determine when to upgrade a process method used to determine when to demote a process method used to determine which queue a process will enter when that process needs service
  • 25. Silberschatz, Galvin and Gagne ©20026.25 Example of Multilevel Feedback Queue Three queues: Q0 – time quantum 8 milliseconds Q1 – time quantum 16 milliseconds Q2 – FCFS Scheduling A new job enters queue Q0 which is served FCFS. When it gains CPU, job receives 8 milliseconds. If it does not finish in 8 milliseconds, job is moved to queue Q1. At Q1 job is again served FCFS and receives 16 additional milliseconds. If it still does not complete, it is preempted and moved to queue Q2.
  • 26. Silberschatz, Galvin and Gagne ©20026.26 Multilevel Feedback Queues
  • 27. Silberschatz, Galvin and Gagne ©20026.27 Multiple-Processor Scheduling CPU scheduling more complex when multiple CPUs are available. Homogeneous processors within a multiprocessor. Load sharing Asymmetric multiprocessing – only one processor accesses the system data structures, alleviating the need for data sharing.
  • 28. Silberschatz, Galvin and Gagne ©20026.28 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.
  • 29. Silberschatz, Galvin and Gagne ©20026.29 Dispatch Latency
  • 30. Silberschatz, Galvin and Gagne ©20026.30 Algorithm Evaluation Deterministic modeling – takes a particular predetermined workload and defines the performance of each algorithm for that workload. Queueing models Implementation
  • 31. Silberschatz, Galvin and Gagne ©20026.31 Evaluation of CPU Schedulers by Simulation
  • 32. Silberschatz, Galvin and Gagne ©20026.32 Solaris 2 Scheduling
  • 33. Silberschatz, Galvin and Gagne ©20026.33 Windows 2000 Priorities