SlideShare a Scribd company logo
1 of 16
Download to read offline
CSE 3201
Operating Systems
CPU Scheduling
Presented by
Mohiuddin Ahmed
Lecturer
Department of CSE
RUET
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 followed by I/O burst
▪ CPU burst distribution is of main concern
Scheduling Criteria
▪ CPU utilization – keep the CPU as busy as possible
▪ Throughput – nubmer 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)
Scheduling Algorithm Optimization Criteria
▪ Max CPU utilization
▪ Max throughput
▪ Min turnaround time
▪ Min waiting time
▪ Min response time
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
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
▪ Consider one CPU-bound and many I/O-bound processes
Shortest-job-first (SJF) Scheduling
▪ Associate with each process the length of its next CPU burst
▪ Use these lengths to schedule the process with the shortest time
▪ SJF is optimal – gives minimum average waiting time for a given set of processes
▪ The difficulty is knowing the length of the next CPU request
▪ Could ask the user
Example of SJF
ProcessArriva l Time Burst Time
P1
0.0 6
P2
2.0 8
P3
4.0 7
P4
5.0 3
▪ SJF scheduling chart
▪ Average waiting time = (3 + 16 + 9 + 0) / 4 = 7
Example of Shortest-remaining-time-first
▪ Now we add the concepts of varying arrival times and preemption to the analysis
ProcessA arri Arrival TimeT Burst Time
P1
0 8
P2
1 4
P3
2 9
P4
3 5
▪ Preemptive SJF Gantt Chart
▪ Average waiting time = [(10-1)+(1-1)+(17-2)+5-3)]/4 = 26/4 = 6.5 msec
▪ If Non-preemptive???
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
▪ Non-preemptive
▪ SJF is priority scheduling where priority is the inverse of predicted next CPU burst
time
▪ Problem ≡ Starvation – low priority processes may never execute
▪ Solution ≡ Aging – as time progresses increase the priority of the process
Example of Priority Scheduling
ProcessA arri Burst TimeT Priority
P1
10 3
P2
1 1
P3
2 4
P4
1 5
P5
5 2
▪ Priority scheduling Gantt Chart
▪ Average waiting time = 8.2 msec
Round Robin (RR)
▪ Each process gets a small unit of CPU time (time quantum q), usually 10-100
milliseconds. After this time has elapsed, the process is preempted and added to the
end of the ready queue.
▪ Timer interrupts every quantum to schedule next process
▪ Performance
▪ q large ⇒ FIFO
▪ q small ⇒ q must be large with respect to context switch, otherwise overhead is too high
Example of RR With Time Quantum = 4
Process Burst Time
P1
24
P2
3
P3
3
▪ The Gantt chart is:
▪ Typically, higher average turnaround than SJF, but better response
▪ q should be large compared to context switch time
▪ q usually 10ms to 100ms, context switch < 10 μsec
Time Quantum and Context Switch Time
q usually 10ms to 100ms, context switch < 10 μsec
Turnaround Time Varies with the Time Quantum
80% of CPU bursts should be
shorter than the time quantum
3/22/2022 16
Thank
You

More Related Content

Similar to CPU Scheduling.pdf

CPU Scheduling Lecture 5 - 6.pptx
CPU Scheduling Lecture 5 - 6.pptxCPU Scheduling Lecture 5 - 6.pptx
CPU Scheduling Lecture 5 - 6.pptxHarry83774
 
Operating Systems Third Unit - Fourth Semester - Engineering
Operating Systems Third Unit  - Fourth Semester - EngineeringOperating Systems Third Unit  - Fourth Semester - Engineering
Operating Systems Third Unit - Fourth Semester - EngineeringYogesh Santhan
 
Process management in os
Process management in osProcess management in os
Process management in osMiong Lazaro
 
Operating System 5
Operating System 5Operating System 5
Operating System 5tech2click
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)Harshit Jain
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithmsPaurav Shah
 
Operating Systems - CPU Scheduling Process
Operating Systems - CPU Scheduling ProcessOperating Systems - CPU Scheduling Process
Operating Systems - CPU Scheduling ProcessChandrakantDivate1
 
Window scheduling algorithm
Window scheduling algorithmWindow scheduling algorithm
Window scheduling algorithmBinal Parekh
 
CPU scheduling algorithms in OS
CPU scheduling algorithms in OSCPU scheduling algorithms in OS
CPU scheduling algorithms in OSharini0810
 
Cpu Schedule Algorithm
Cpu Schedule AlgorithmCpu Schedule Algorithm
Cpu Schedule AlgorithmArchit Jain
 
AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...
AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...
AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...Shanmuganathan C
 
Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Nagarajan
 

Similar to CPU Scheduling.pdf (20)

CPU Scheduling Lecture 5 - 6.pptx
CPU Scheduling Lecture 5 - 6.pptxCPU Scheduling Lecture 5 - 6.pptx
CPU Scheduling Lecture 5 - 6.pptx
 
Operating Systems Third Unit - Fourth Semester - Engineering
Operating Systems Third Unit  - Fourth Semester - EngineeringOperating Systems Third Unit  - Fourth Semester - Engineering
Operating Systems Third Unit - Fourth Semester - Engineering
 
Process management in os
Process management in osProcess management in os
Process management in os
 
Process Scheduling
Process SchedulingProcess Scheduling
Process Scheduling
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
 
CH06.pdf
CH06.pdfCH06.pdf
CH06.pdf
 
OS_Ch6
OS_Ch6OS_Ch6
OS_Ch6
 
OSCh6
OSCh6OSCh6
OSCh6
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)
 
5 Process Scheduling
5 Process Scheduling5 Process Scheduling
5 Process Scheduling
 
Ch5
Ch5Ch5
Ch5
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Operating Systems - CPU Scheduling Process
Operating Systems - CPU Scheduling ProcessOperating Systems - CPU Scheduling Process
Operating Systems - CPU Scheduling Process
 
Window scheduling algorithm
Window scheduling algorithmWindow scheduling algorithm
Window scheduling algorithm
 
CPU scheduling algorithms in OS
CPU scheduling algorithms in OSCPU scheduling algorithms in OS
CPU scheduling algorithms in OS
 
Cpu Schedule Algorithm
Cpu Schedule AlgorithmCpu Schedule Algorithm
Cpu Schedule Algorithm
 
AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...
AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...
AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...
 
Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Scheduling algorithm (chammu)
Scheduling algorithm (chammu)
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 

Recently uploaded

Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesChandrakantDivate1
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxpritamlangde
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...ronahami
 
fitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .pptfitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .pptAfnanAhmad53
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfsumitt6_25730773
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...ppkakm
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 

Recently uploaded (20)

FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To Curves
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
 
fitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .pptfitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .ppt
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdf
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Signal Processing and Linear System Analysis
Signal Processing and Linear System AnalysisSignal Processing and Linear System Analysis
Signal Processing and Linear System Analysis
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 

CPU Scheduling.pdf

  • 1. CSE 3201 Operating Systems CPU Scheduling Presented by Mohiuddin Ahmed Lecturer Department of CSE RUET
  • 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 followed by I/O burst ▪ CPU burst distribution is of main concern
  • 3. Scheduling Criteria ▪ CPU utilization – keep the CPU as busy as possible ▪ Throughput – nubmer 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)
  • 4. Scheduling Algorithm Optimization Criteria ▪ Max CPU utilization ▪ Max throughput ▪ Min turnaround time ▪ Min waiting time ▪ Min response time
  • 5. 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
  • 6. 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 ▪ Consider one CPU-bound and many I/O-bound processes
  • 7. Shortest-job-first (SJF) Scheduling ▪ Associate with each process the length of its next CPU burst ▪ Use these lengths to schedule the process with the shortest time ▪ SJF is optimal – gives minimum average waiting time for a given set of processes ▪ The difficulty is knowing the length of the next CPU request ▪ Could ask the user
  • 8. Example of SJF ProcessArriva l Time Burst Time P1 0.0 6 P2 2.0 8 P3 4.0 7 P4 5.0 3 ▪ SJF scheduling chart ▪ Average waiting time = (3 + 16 + 9 + 0) / 4 = 7
  • 9. Example of Shortest-remaining-time-first ▪ Now we add the concepts of varying arrival times and preemption to the analysis ProcessA arri Arrival TimeT Burst Time P1 0 8 P2 1 4 P3 2 9 P4 3 5 ▪ Preemptive SJF Gantt Chart ▪ Average waiting time = [(10-1)+(1-1)+(17-2)+5-3)]/4 = 26/4 = 6.5 msec ▪ If Non-preemptive???
  • 10. 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 ▪ Non-preemptive ▪ SJF is priority scheduling where priority is the inverse of predicted next CPU burst time ▪ Problem ≡ Starvation – low priority processes may never execute ▪ Solution ≡ Aging – as time progresses increase the priority of the process
  • 11. Example of Priority Scheduling ProcessA arri Burst TimeT Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 ▪ Priority scheduling Gantt Chart ▪ Average waiting time = 8.2 msec
  • 12. Round Robin (RR) ▪ Each process gets a small unit of CPU time (time quantum q), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. ▪ Timer interrupts every quantum to schedule next process ▪ Performance ▪ q large ⇒ FIFO ▪ q small ⇒ q must be large with respect to context switch, otherwise overhead is too high
  • 13. Example of RR With Time Quantum = 4 Process Burst Time P1 24 P2 3 P3 3 ▪ The Gantt chart is: ▪ Typically, higher average turnaround than SJF, but better response ▪ q should be large compared to context switch time ▪ q usually 10ms to 100ms, context switch < 10 μsec
  • 14. Time Quantum and Context Switch Time q usually 10ms to 100ms, context switch < 10 μsec
  • 15. Turnaround Time Varies with the Time Quantum 80% of CPU bursts should be shorter than the time quantum