SlideShare a Scribd company logo
1
Operating System
Process Scheduling
(Ch 4.2, 5.1 - 5.3)
Schedulers
F Short-Term
– “Which process gets the CPU?”
– Fast, since once per 100 ms
F Long-Term (batch)
– “Which process gets the Ready Queue?”
F Medium-Term (Unix)
– “Which Ready Queue process to memory?”
– Swapping
CPU-IO Burst Cycle
add
read
(I/O Wait)
store
increment
write
(I/O Wait)
Burst Duration
Frequency
Preemptive Scheduling
F Four times to re-schedule
1 Running to Waiting (I/O wait)
2 Running to Ready (time slice)
3 Waiting to Ready (I/O completion)
4 Termination
F #2 optional ==> “Preemptive”
F Timing may cause unexpected results
– updating shared variable
– kernel saving state
Question
F What Performance Criteria Should the
Scheduler Seek to Optimize?
– Ex: CPU minimize time spent in queue
– Others?
Scheduling Criteria
1 CPU utilization (40 to 90)
2 Throughput (processes / hour)
3 Turn-around time
4 Waiting time (in queue)
F Maximize #1, #2 Minimize #3, #4
F Response time
– Self-regulated by users (go home)
– Bounded ==> Variance!
2
First-Come, First-Served
Process
A
B
C
Burst Time
8
1
1
0 8 9 10
A B C
F Avg Wait Time (0 + 8 + 9) / 3 = 5.7
Gantt
Chart
Shortest Job First
0 1 2 10
A
B C
F Avg Wait Time (0 + 1 + 2) / 3 = 1
F OptimalAvg Wait
F Prediction tough … Ideas?
Process
A
B
C
Burst Time
8
1
1
Priority Scheduling
F SJF is a special case
Process
A
B
C
Burst Time
8
1
1
Priority
2
1
3
0 1 9 10
A
B C
F Avg Wait Time (0 + 1 + 9) / 3 = 3.3
Priority Scheduling Criteria?
F Internal
– open files
– memory requirements
– CPU time used - time slice expired (RR)
– process age - I/O wait completed
F External
– $
– department sponsoring work
– process importance
– super-user (root) - nice
Round Robin
F Fixed time-slice and Preemption
Process
A
B
C
Burst Time
5
3
3
B C
A B C A B C
A A
F Avg = (8 + 9 + 11) / 3 = 9.3
F FCFS? SJF?
8 9 11
Round Robin Fun
Process
A
B
C
Burst Time
10
10
10
F Turn-around time?
– q = 10
– q = 1
– q --> 0
3
More Round Robin Fun
Process
A
B
C
D
Burst Time
6
3
1
7
1 2 3 4 5 6 7
Time Quantum
Avg.
Turn-around
Time
Rule:
80% within
one quantum
Fun with Scheduling
Process
A
B
C
Burst Time
10
1
2
Priority
2
1
3
F Gantt Charts:
– FCFS
– SJF
– Priority
– RR (q=1)
F Performance:
– Throughput
– Waiting time
– Turnaround time
More Fun with Scheduling
Process
A
B
C
Arrival Time
0.0
0.4
1.0
Burst Time
8
4
1
F Turn around time:
– FCFS
– SJF
– q=1 CPU idle
– q=0.5 CPU idle
Multi-Level Queues
System
Priority 1
Priority 2
Priority 3
Interactive
Batch
F Categories of processes
F Run all in 1 first, then 2 …
F Starvation!
F Divide between queues: 70% 1, 15% 2 …
... ...
Multi-Level Feedback Queues
Queue
Priority 1
Priority 2
Priority 3
Queue
Queue
1 Quantum
2 Quanta
4 Quanta
F Time slice expensive but want interactive
F Consider process needing 100 quanta
– 1, 4, 8, 16, 32, 64 = 7 swaps!
F Favor interactive users
... ... ...
Evaluating Scheduling Algorithms
F With all these possible scheduling
algorithms, how to choose one?
– Ease of implementation
– Efficiency of implementation / low overhead
– Performance evaluation (next slide)
4
Performance Evaluation Methods
F Deterministic methods / Gantt charts
– Use more realistic workloads
F Queueing theory
– Mathematical techniques
– Uses probablistic models of jobs / CPU
utilization
F Simulation
– Probabilistic or trace-driven
Linux Process Scheduling
F Two classes of processes:
– Real-Time
– Normal
F Real-Time:
– Always run Real-Time above Normal
– Round-Robin or FIFO
– “Soft” not “Hard”
Linux Process Scheduling
F Normal: Credit-Based
– process with most credits is selected
– time-slice then lose a credit (0, then suspend)
– no runnable process (all suspended), add to
every process:
credits = credits/2 + priority
F Automatically favors I/O bound processes
Questions
F What is a PCB?
F List steps that occur during interrupt
F Explain how SJF works
F True or False:
– FCFS is optimal in terms of avg waiting time
– Most processes are CPU bound
– The shorter the time quantum, the better
F micro-shell.c?
Interrupt Handling
F Stores program counter (hardware)
F Loads new program counter (hardware)
– jump to interrupt service procedure
F Save PCB information (assembly)
F Set up new stack (assembly)
F Set “waiting” process to “ready” (C)
F Re-schedule (probably awakened process) (C)
– “dispatcher” in SOS, “schedule” in Linux
F If new process, called a context-switch
Outline
F Processes 4
– PCB 4
– Interrupt Handlers 4
F Scheduling
– Algorithms 4
– Linux
– WinNT ←
5
Windows NT Scheduling
F Basic scheduling unit is a thread
F Priority based scheduling per thread
F Preemptive operating system
F No shortest job first, no quotas
Priority Assignment
F NT kernel uses 31 priority levels
– 31 is the highest; 0 is system idle thread
– Realtimepriorities: 16 - 31
– Dynamic priorities: 1 - 15
F Users specify a priority class:
u realtime (24) , high (13), normal (8) and idle (4)
– and a relative priority:
u highest (+2), above normal (+1), normal (0), below
normal (-1), and lowest (-2)
– to establish the starting priority
F Threads also have a current priority
Quantum
F Determines how long a Thread runs once
selected
F Varies based on:
– NT Workstation or NT Server
– Intel or Alpha hardware
– Foreground/Background application threads
F How do you think it varies with each?
Dispatcher Ready List
F Keeps track of all
Ready-to-execute
threads
F Queue of threads
assigned to each level
Dispatcher
Ready List
11
10
9
8
7
Ready Threads
FindReadyThread
F Locates the highest priority thread that is
ready to execute
F Scans dispatcher ready list
F Picks front thread in highest priority
nonempty queue
F When is this like round robin?
Boosting and Decay
F Boost priority
– Event that “wakes” blocked thread
– Boosts never exceed priority 15 for dynamic
– Realtime priorities are not boosted
F Decay priority
– by one for each quantum
– decays only to starting priority (no lower)
6
Starvation Prevention
F Low priority threads may never execute
F “Anti-CPU starvation policy”
– thread that has not executed for 3 seconds
– boost priority to 15
– double quantum
F Decay is swift not gradual after this boost

More Related Content

What's hot

CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
SyedTalhaBukhari2
 
Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Nagarajan
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
Abhijith Reloaded
 
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
 
Process Scheduling
Process SchedulingProcess Scheduling
Process Scheduling
Abhishek Nagar
 
Processor / CPU Scheduling
Processor / CPU SchedulingProcessor / CPU Scheduling
Processor / CPU Scheduling
Izaz Roghani
 
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round RobinComparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Universitas Pembangunan Panca Budi
 
5 Process Scheduling
5 Process Scheduling5 Process Scheduling
5 Process Scheduling
Dr. Loganathan R
 
First-Come-First-Serve (FCFS)
First-Come-First-Serve (FCFS)First-Come-First-Serve (FCFS)
First-Come-First-Serve (FCFS)nikeAthena
 
Process scheduling : operating system ( Btech cse )
Process scheduling : operating system ( Btech cse )Process scheduling : operating system ( Btech cse )
Process scheduling : operating system ( Btech cse )
HimanshuSharma1389
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
Chankey Pathak
 

What's hot (20)

CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Scheduling algorithm (chammu)
Scheduling algorithm (chammu)
 
OS_Ch6
OS_Ch6OS_Ch6
OS_Ch6
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)
 
Cp usched 2
Cp usched  2Cp usched  2
Cp usched 2
 
OSCh6
OSCh6OSCh6
OSCh6
 
Cpu Scheduling Galvin
Cpu Scheduling GalvinCpu Scheduling Galvin
Cpu Scheduling Galvin
 
Process Scheduling
Process SchedulingProcess Scheduling
Process Scheduling
 
Ch05
Ch05Ch05
Ch05
 
Sa by shekhar
Sa by shekharSa by shekhar
Sa by shekhar
 
Os module 2 ba
Os module 2 baOs module 2 ba
Os module 2 ba
 
Processor / CPU Scheduling
Processor / CPU SchedulingProcessor / CPU Scheduling
Processor / CPU Scheduling
 
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round RobinComparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
 
5 Process Scheduling
5 Process Scheduling5 Process Scheduling
5 Process Scheduling
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
First-Come-First-Serve (FCFS)
First-Come-First-Serve (FCFS)First-Come-First-Serve (FCFS)
First-Come-First-Serve (FCFS)
 
Process scheduling : operating system ( Btech cse )
Process scheduling : operating system ( Btech cse )Process scheduling : operating system ( Btech cse )
Process scheduling : operating system ( Btech cse )
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 

Similar to Scheduling

Process management in os
Process management in osProcess management in os
Process management in os
Miong Lazaro
 
Os5 2
Os5 2Os5 2
Os5 2issbp
 
Csc4320 chapter 5 2
Csc4320 chapter 5 2Csc4320 chapter 5 2
Csc4320 chapter 5 2pri534
 
cpu sechduling
cpu sechduling cpu sechduling
cpu sechduling gopi7
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
sammerkhan1
 
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationUnit iios process scheduling and synchronization
Unit iios process scheduling and synchronization
donny101
 
dataprocess using different technology.ppt
dataprocess using different technology.pptdataprocess using different technology.ppt
dataprocess using different technology.ppt
ssuserf6eb9b
 
Process Scheduling
Process SchedulingProcess Scheduling
Ch6
Ch6Ch6
Ch6C.U
 
Process and CPU scheduler
Process and CPU schedulerProcess and CPU scheduler
Process and CPU scheduler
Shivbhawan Verma
 
CPU scheduling
CPU schedulingCPU scheduling
CPU scheduling
Amir Khan
 
Window scheduling algorithm
Window scheduling algorithmWindow scheduling algorithm
Window scheduling algorithm
Binal Parekh
 
UNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxUNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptx
ansariparveen06
 
Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-scheduling
Nazir Ahmed
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithms
sathish sak
 
csc4320chapter5-2-101203002830-phpapp01.pdf
csc4320chapter5-2-101203002830-phpapp01.pdfcsc4320chapter5-2-101203002830-phpapp01.pdf
csc4320chapter5-2-101203002830-phpapp01.pdf
AkarshNag
 

Similar to Scheduling (20)

Process management in os
Process management in osProcess management in os
Process management in os
 
Os5 2
Os5 2Os5 2
Os5 2
 
Csc4320 chapter 5 2
Csc4320 chapter 5 2Csc4320 chapter 5 2
Csc4320 chapter 5 2
 
Os2
Os2Os2
Os2
 
cpu sechduling
cpu sechduling cpu sechduling
cpu sechduling
 
Ch5
Ch5Ch5
Ch5
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationUnit iios process scheduling and synchronization
Unit iios process scheduling and synchronization
 
dataprocess using different technology.ppt
dataprocess using different technology.pptdataprocess using different technology.ppt
dataprocess using different technology.ppt
 
Planificacion
PlanificacionPlanificacion
Planificacion
 
Ch5 answers
Ch5 answersCh5 answers
Ch5 answers
 
Process Scheduling
Process SchedulingProcess Scheduling
Process Scheduling
 
Ch6
Ch6Ch6
Ch6
 
Process and CPU scheduler
Process and CPU schedulerProcess and CPU scheduler
Process and CPU scheduler
 
CPU scheduling
CPU schedulingCPU scheduling
CPU scheduling
 
Window scheduling algorithm
Window scheduling algorithmWindow scheduling algorithm
Window scheduling algorithm
 
UNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxUNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptx
 
Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-scheduling
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithms
 
csc4320chapter5-2-101203002830-phpapp01.pdf
csc4320chapter5-2-101203002830-phpapp01.pdfcsc4320chapter5-2-101203002830-phpapp01.pdf
csc4320chapter5-2-101203002830-phpapp01.pdf
 

More from Ankit Dubey

Unit 1 android and it's tools quiz {mad cwipedia}
Unit 1 android and it's tools quiz {mad cwipedia}Unit 1 android and it's tools quiz {mad cwipedia}
Unit 1 android and it's tools quiz {mad cwipedia}
Ankit Dubey
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
Ankit Dubey
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
Ankit Dubey
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
Ankit Dubey
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
Ankit Dubey
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
Ankit Dubey
 
Ch4 threads
Ch4 threadsCh4 threads
Ch4 threads
Ankit Dubey
 
Ch3 processes
Ch3 processesCh3 processes
Ch3 processes
Ankit Dubey
 
Ch2 system structure
Ch2 system structureCh2 system structure
Ch2 system structure
Ankit Dubey
 
Ch1 introduction-to-os
Ch1 introduction-to-osCh1 introduction-to-os
Ch1 introduction-to-os
Ankit Dubey
 
Android i
Android iAndroid i
Android i
Ankit Dubey
 
Mongodb mock test_ii
Mongodb mock test_iiMongodb mock test_ii
Mongodb mock test_ii
Ankit Dubey
 
Android mock test_iii
Android mock test_iiiAndroid mock test_iii
Android mock test_iii
Ankit Dubey
 
Android mock test_ii
Android mock test_iiAndroid mock test_ii
Android mock test_ii
Ankit Dubey
 
Ajp notes-chapter-06
Ajp notes-chapter-06Ajp notes-chapter-06
Ajp notes-chapter-06
Ankit Dubey
 
Ajp notes-chapter-05
Ajp notes-chapter-05Ajp notes-chapter-05
Ajp notes-chapter-05
Ankit Dubey
 
Ajp notes-chapter-04
Ajp notes-chapter-04Ajp notes-chapter-04
Ajp notes-chapter-04
Ankit Dubey
 
Ajp notes-chapter-03
Ajp notes-chapter-03Ajp notes-chapter-03
Ajp notes-chapter-03
Ankit Dubey
 
Ajp notes-chapter-02
Ajp notes-chapter-02Ajp notes-chapter-02
Ajp notes-chapter-02
Ankit Dubey
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
Ankit Dubey
 

More from Ankit Dubey (20)

Unit 1 android and it's tools quiz {mad cwipedia}
Unit 1 android and it's tools quiz {mad cwipedia}Unit 1 android and it's tools quiz {mad cwipedia}
Unit 1 android and it's tools quiz {mad cwipedia}
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Ch4 threads
Ch4 threadsCh4 threads
Ch4 threads
 
Ch3 processes
Ch3 processesCh3 processes
Ch3 processes
 
Ch2 system structure
Ch2 system structureCh2 system structure
Ch2 system structure
 
Ch1 introduction-to-os
Ch1 introduction-to-osCh1 introduction-to-os
Ch1 introduction-to-os
 
Android i
Android iAndroid i
Android i
 
Mongodb mock test_ii
Mongodb mock test_iiMongodb mock test_ii
Mongodb mock test_ii
 
Android mock test_iii
Android mock test_iiiAndroid mock test_iii
Android mock test_iii
 
Android mock test_ii
Android mock test_iiAndroid mock test_ii
Android mock test_ii
 
Ajp notes-chapter-06
Ajp notes-chapter-06Ajp notes-chapter-06
Ajp notes-chapter-06
 
Ajp notes-chapter-05
Ajp notes-chapter-05Ajp notes-chapter-05
Ajp notes-chapter-05
 
Ajp notes-chapter-04
Ajp notes-chapter-04Ajp notes-chapter-04
Ajp notes-chapter-04
 
Ajp notes-chapter-03
Ajp notes-chapter-03Ajp notes-chapter-03
Ajp notes-chapter-03
 
Ajp notes-chapter-02
Ajp notes-chapter-02Ajp notes-chapter-02
Ajp notes-chapter-02
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 

Recently uploaded

DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
veerababupersonal22
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
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
 
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
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
top1002
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 

Recently uploaded (20)

DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
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
 
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
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 

Scheduling

  • 1. 1 Operating System Process Scheduling (Ch 4.2, 5.1 - 5.3) Schedulers F Short-Term – “Which process gets the CPU?” – Fast, since once per 100 ms F Long-Term (batch) – “Which process gets the Ready Queue?” F Medium-Term (Unix) – “Which Ready Queue process to memory?” – Swapping CPU-IO Burst Cycle add read (I/O Wait) store increment write (I/O Wait) Burst Duration Frequency Preemptive Scheduling F Four times to re-schedule 1 Running to Waiting (I/O wait) 2 Running to Ready (time slice) 3 Waiting to Ready (I/O completion) 4 Termination F #2 optional ==> “Preemptive” F Timing may cause unexpected results – updating shared variable – kernel saving state Question F What Performance Criteria Should the Scheduler Seek to Optimize? – Ex: CPU minimize time spent in queue – Others? Scheduling Criteria 1 CPU utilization (40 to 90) 2 Throughput (processes / hour) 3 Turn-around time 4 Waiting time (in queue) F Maximize #1, #2 Minimize #3, #4 F Response time – Self-regulated by users (go home) – Bounded ==> Variance!
  • 2. 2 First-Come, First-Served Process A B C Burst Time 8 1 1 0 8 9 10 A B C F Avg Wait Time (0 + 8 + 9) / 3 = 5.7 Gantt Chart Shortest Job First 0 1 2 10 A B C F Avg Wait Time (0 + 1 + 2) / 3 = 1 F OptimalAvg Wait F Prediction tough … Ideas? Process A B C Burst Time 8 1 1 Priority Scheduling F SJF is a special case Process A B C Burst Time 8 1 1 Priority 2 1 3 0 1 9 10 A B C F Avg Wait Time (0 + 1 + 9) / 3 = 3.3 Priority Scheduling Criteria? F Internal – open files – memory requirements – CPU time used - time slice expired (RR) – process age - I/O wait completed F External – $ – department sponsoring work – process importance – super-user (root) - nice Round Robin F Fixed time-slice and Preemption Process A B C Burst Time 5 3 3 B C A B C A B C A A F Avg = (8 + 9 + 11) / 3 = 9.3 F FCFS? SJF? 8 9 11 Round Robin Fun Process A B C Burst Time 10 10 10 F Turn-around time? – q = 10 – q = 1 – q --> 0
  • 3. 3 More Round Robin Fun Process A B C D Burst Time 6 3 1 7 1 2 3 4 5 6 7 Time Quantum Avg. Turn-around Time Rule: 80% within one quantum Fun with Scheduling Process A B C Burst Time 10 1 2 Priority 2 1 3 F Gantt Charts: – FCFS – SJF – Priority – RR (q=1) F Performance: – Throughput – Waiting time – Turnaround time More Fun with Scheduling Process A B C Arrival Time 0.0 0.4 1.0 Burst Time 8 4 1 F Turn around time: – FCFS – SJF – q=1 CPU idle – q=0.5 CPU idle Multi-Level Queues System Priority 1 Priority 2 Priority 3 Interactive Batch F Categories of processes F Run all in 1 first, then 2 … F Starvation! F Divide between queues: 70% 1, 15% 2 … ... ... Multi-Level Feedback Queues Queue Priority 1 Priority 2 Priority 3 Queue Queue 1 Quantum 2 Quanta 4 Quanta F Time slice expensive but want interactive F Consider process needing 100 quanta – 1, 4, 8, 16, 32, 64 = 7 swaps! F Favor interactive users ... ... ... Evaluating Scheduling Algorithms F With all these possible scheduling algorithms, how to choose one? – Ease of implementation – Efficiency of implementation / low overhead – Performance evaluation (next slide)
  • 4. 4 Performance Evaluation Methods F Deterministic methods / Gantt charts – Use more realistic workloads F Queueing theory – Mathematical techniques – Uses probablistic models of jobs / CPU utilization F Simulation – Probabilistic or trace-driven Linux Process Scheduling F Two classes of processes: – Real-Time – Normal F Real-Time: – Always run Real-Time above Normal – Round-Robin or FIFO – “Soft” not “Hard” Linux Process Scheduling F Normal: Credit-Based – process with most credits is selected – time-slice then lose a credit (0, then suspend) – no runnable process (all suspended), add to every process: credits = credits/2 + priority F Automatically favors I/O bound processes Questions F What is a PCB? F List steps that occur during interrupt F Explain how SJF works F True or False: – FCFS is optimal in terms of avg waiting time – Most processes are CPU bound – The shorter the time quantum, the better F micro-shell.c? Interrupt Handling F Stores program counter (hardware) F Loads new program counter (hardware) – jump to interrupt service procedure F Save PCB information (assembly) F Set up new stack (assembly) F Set “waiting” process to “ready” (C) F Re-schedule (probably awakened process) (C) – “dispatcher” in SOS, “schedule” in Linux F If new process, called a context-switch Outline F Processes 4 – PCB 4 – Interrupt Handlers 4 F Scheduling – Algorithms 4 – Linux – WinNT ←
  • 5. 5 Windows NT Scheduling F Basic scheduling unit is a thread F Priority based scheduling per thread F Preemptive operating system F No shortest job first, no quotas Priority Assignment F NT kernel uses 31 priority levels – 31 is the highest; 0 is system idle thread – Realtimepriorities: 16 - 31 – Dynamic priorities: 1 - 15 F Users specify a priority class: u realtime (24) , high (13), normal (8) and idle (4) – and a relative priority: u highest (+2), above normal (+1), normal (0), below normal (-1), and lowest (-2) – to establish the starting priority F Threads also have a current priority Quantum F Determines how long a Thread runs once selected F Varies based on: – NT Workstation or NT Server – Intel or Alpha hardware – Foreground/Background application threads F How do you think it varies with each? Dispatcher Ready List F Keeps track of all Ready-to-execute threads F Queue of threads assigned to each level Dispatcher Ready List 11 10 9 8 7 Ready Threads FindReadyThread F Locates the highest priority thread that is ready to execute F Scans dispatcher ready list F Picks front thread in highest priority nonempty queue F When is this like round robin? Boosting and Decay F Boost priority – Event that “wakes” blocked thread – Boosts never exceed priority 15 for dynamic – Realtime priorities are not boosted F Decay priority – by one for each quantum – decays only to starting priority (no lower)
  • 6. 6 Starvation Prevention F Low priority threads may never execute F “Anti-CPU starvation policy” – thread that has not executed for 3 seconds – boost priority to 15 – double quantum F Decay is swift not gradual after this boost