COS 318: Operating Systems CPU Scheduling: Andy Bavier Computer Science Department Princeton University
COS 318: Operating Systems CPU Scheduling: Andy Bavier Computer Science Department Princeton University
CPU Scheduling
Andy Bavier
Computer Science Department
Princeton University
http://www.cs.princeton.edu/courses/archive/fall10/cos318/
Todays Topics
CPU scheduling basics
CPU Scheduling algorithms
When to Schedule?
Process/thread creation
Process/thread exit
Blocking on I/O or synchronization
I/O interrupt
Clock interrupt (pre-emptive scheduling)
Preemptive
scheduling
Terminate
Exited
(call scheduler)
Scheduler
dispatch Running
Non-preemptive
scheduling
Running ready
Blocked ready
Running blocked
Terminate
Yield, Interrupt
(call scheduler)
Ready
Running ready
Blocked ready
Blocked
Create
Batch vs interactive
vs real-time
Resource free,
I/O completion interrupt
(move to ready queue)
4
Scheduling Criteria
Assumptions
Scheduling Criteria
Questions:
Problem Cases
B never runs.
Todays Topics
CPU scheduling basics
CPU Scheduling algorithms
Scheduling Algorithms
Example 1
P1
P2
P3
Example 2
P2
P3
P1
(Gantt Graph)
Non-preemptive
Shortest
Preemptive version
Example
P4
Can
P1
P3
P2
Round Robin
Current
process
Example
Comparisons
Timeout
Dispatch
CPU
Aux queue
I/O wait
I/O wait
I/O wait
15
Priority Scheduling
Obvious
The
method
Why
Multiple Queues
Priority
4
3
2
1
Time slices
1
2
4
8
Lottery Scheduling
Motivations
Lottery method
Question
CPU
L1 $
L2 $
CPU
L1 $
L2 $
Memory
Multiprocessor architecture
Cache coherence
Single OS
Network
Cluster or multicomputer
Distributed memory
An OS in each box
19
Multiprocessor/Cluster Scheduling
Design
issue
Gang
scheduling (co-scheduling)
Dedicated
processor assignment
20
Real-Time Scheduling
Two
types of real-time
Hard deadline
Must meet, otherwise can cause fatal error
Soft Deadline
Meet most of the time, but not mandatory
Admission
control
Ci 1
Ti
Assumptions
Example
Main
idea of EDF
Example
23
1 sec preemption
Priorities
Swapper
Block I/O device control
File operations
Character I/O device control
User processes
24
Linux Scheduling
Time-sharing scheduling
Real-time scheduling
Windows Scheduling
Classes
and priorities
scheduler
Multiprocessor
scheduling
26
Summary
Scheduling algorithms
27