nus.soc.cs5248 ooi wei tsang 1 cpu scheduling. nus.soc.cs5248 ooi wei tsang 2 scheduling task vs i/o...
TRANSCRIPT
NUS.SOC.CS5248Ooi Wei Tsang
2
Scheduling Task vs I/O RequestTask computation time
unpredictable
Task can be preemptive
NUS.SOC.CS5248Ooi Wei Tsang
3
CPU Scheduling Algorithm
FCFSPriority-basedProportional fair-shareEDFRate monotonic
NUS.SOC.CS5248Ooi Wei Tsang
6
Problem
How can multimedia applications co-exists with normal applications?
NUS.SOC.CS5248Ooi Wei Tsang
7
Same Idea as Cello
P. Goyal, X. Guo, and H. M. Vin.
“A hierarchical CPU scheduler formultimedia operating systems.”
OSDI’96
NUS.SOC.CS5248Ooi Wei Tsang
8
Guarantee?
So far: Best-Effort Real-Time Scheduling
What about: Guaranteed service?
NUS.SOC.CS5248Ooi Wei Tsang
12
Example: Memory
How to reserve?malloc
Overbook? return NULL
Overuse? crash, throw exception
NUS.SOC.CS5248Ooi Wei Tsang
13
Example: CPU
How to reserve?Overbook?Overuse?
Memory is discrete. CPU time is continuous.
NUS.SOC.CS5248Ooi Wei Tsang
18
Effects of T and C
0%10%20%30%40%50%60%70%80%90%
100%
0 10 20 30 40 50 60Reservation Period (ms)
% F
ram
es
Re
ndere
d
20% 15% 10%
NUS.SOC.CS5248Ooi Wei Tsang
19
Schedulability Theorems
Rate Monotonic Scheduler
Earliest Deadline First
NUS.SOC.CS5248Ooi Wei Tsang
20
Assumptions
programs are periodiccomputation time is constant zero context switch timeprograms are independent
21
NUS.SOC.CS5248Ooi Wei Tsang
Rialto SchedulerCPU Reservations and Time Contraints: Efficient and Predictable Scheduling of Independent Activities,M. Jones, D. Rosu and M. Rosu
NUS.SOC.CS5248Ooi Wei Tsang
22
Why Rialto?
Provide CPU reservationEnable deadlinesCo-exists with best-effort apps
NUS.SOC.CS5248Ooi Wei Tsang
23
Overview
input: a set of tasks and their reservation
pre-compute a scheduling graph
schedule tasks based on scheduling graph
NUS.SOC.CS5248Ooi Wei Tsang
26
Advantages
Only need to make new scheduling decisions when new task is added
NUS.SOC.CS5248Ooi Wei Tsang
27
Computing Scheduling Graph Input: A set of tasks with their
reservationsOutput: A scheduling graph if
feasible
NUS.SOC.CS5248Ooi Wei Tsang
30
Computing Scheduling Graph
Input: A set of tasks with their reservations
Output: A scheduling graph if feasible
Goals: (a) Minimize context switches (b) Distribute free time evenly
NUS.SOC.CS5248Ooi Wei Tsang
36
Time Constraint
“I need to run the following code, that takes 30ms, 100ms from now, and the deadline is (now+180ms).”
NUS.SOC.CS5248Ooi Wei Tsang
37
Pseudocode
can = begin_constraint(start_time, deadline, estimate)
if can schedule thendo work
elseadapt
time_taken = end_constraint()
NUS.SOC.CS5248Ooi Wei Tsang
39
Advantages
Only need to make new scheduling decisions when new task is added
Feasibility of time constraint can be predicted accurately
NUS.SOC.CS5248Ooi Wei Tsang
42
Look inside NT Scheduler
Scheduling unit : ThreadPriority level: 1-15, 16-31
rt 24 high 13 normal 8 idle 4
NUS.SOC.CS5248Ooi Wei Tsang
43
Priority Boosting
Example: Priority +6 after awaken by
keyboard input
NUS.SOC.CS5248Ooi Wei Tsang
44
Anti-Starvation
If hasn’t run for 3 seconds Boost priority to 14
Avoid “Priority Inversion”
NUS.SOC.CS5248Ooi Wei Tsang
47
Win Media Player 6.4
Period Priority Thread
10 24 Kernel Mixer
45 8 GUI
100 15 Timer
100 9 MP3 Decoder
500 8 Unknown
2000 8 Disk Reader
NUS.SOC.CS5248Ooi Wei Tsang
48
Experiment 1
WMP running alone
Period Priority Thread
10 24 Kernel Mixer
45 8 GUI
100 15 Timer
100 9 MP3 Decoder
500 8 Unknown
2000 8 Disk Reader
NUS.SOC.CS5248Ooi Wei Tsang
49
Experiment 2
WMP running with priority 8 competitor
Period Priority Thread
10 24 Kernel Mixer
45 8 GUI
100 15 Timer
100 9 MP3 Decoder
500 8 Unknown
2000 8 Disk Reader
NUS.SOC.CS5248Ooi Wei Tsang
50
Experiment 3
WMP running with priority 10 competitor
Period Priority Thread
10 24 Kernel Mixer
45 8 GUI
100 15 Timer
100 9 MP3 Decoder
500 8 Unknown
2000 8 Disk Reader
NUS.SOC.CS5248Ooi Wei Tsang
51
Experiment 5
WMP running with priority 10 competitor
Period Priority Reservation Thread
10 24 Kernel Mixer
45 8 GUI
100 15 Timer
100 9 40/1024 MP3 Decoder
500 8 Unknown
2000 8 Disk Reader
NUS.SOC.CS5248Ooi Wei Tsang
52
Experiment 6
WMP running with priority 10 competitor
Period Priority Reservation Thread
10 24 1/16 Kernel Mixer
45 8 GUI
100 15 Timer
100 9 40/1024 MP3 Decoder
500 8 Unknown
2000 8 Disk Reader
NUS.SOC.CS5248Ooi Wei Tsang
53
Experiment 7
WMP running with priority 10 competitor
Period Priority Reservation Thread
10 24 Kernel Mixer
45 8 GUI
100 15 Timer
100 9 20/512 MP3 Decoder
500 8 Unknown
2000 8 Disk Reader