Download presentation
Presentation is loading. Please wait.
Published byAubrie Cannon Modified over 9 years ago
1
NUS.SOC.CS5248 Ooi Wei Tsang 1 CPU Scheduling
2
NUS.SOC.CS5248 Ooi Wei Tsang 2 Scheduling Task vs I/O Request Task computation time unpredictable Task can be preemptive
3
NUS.SOC.CS5248 Ooi Wei Tsang 3 CPU Scheduling Algorithm FCFS Priority-based Proportional fair-share EDF Rate monotonic
4
NUS.SOC.CS5248 Ooi Wei Tsang 4 Rate Monotonic
5
NUS.SOC.CS5248 Ooi Wei Tsang 5 EDF
6
NUS.SOC.CS5248 Ooi Wei Tsang 6 Problem How can multimedia applications co-exists with normal applications?
7
NUS.SOC.CS5248 Ooi Wei Tsang 7 Same Idea as Cello P. Goyal, X. Guo, and H. M. Vin. “A hierarchical CPU scheduler for multimedia operating systems.” OSDI’96
8
NUS.SOC.CS5248 Ooi Wei Tsang 8 Guarantee? So far: Best-Effort Real-Time Scheduling What about: Guaranteed service?
9
NUS.SOC.CS5248 Ooi Wei Tsang 9 How to Guarantee Services?
10
NUS.SOC.CS5248 Ooi Wei Tsang 10 Resource Reservation: CPU
11
NUS.SOC.CS5248 Ooi Wei Tsang 11 Resource Reservations How to reserve? Overbook? Overuse?
12
NUS.SOC.CS5248 Ooi Wei Tsang 12 Example: Memory How to reserve? malloc Overbook? return NULL Overuse? crash, throw exception
13
NUS.SOC.CS5248 Ooi Wei Tsang 13 Example: CPU How to reserve? Overbook? Overuse? Memory is discrete. CPU time is continuous.
14
NUS.SOC.CS5248 Ooi Wei Tsang 14 How to Reserve?
15
NUS.SOC.CS5248 Ooi Wei Tsang 15 CPU Reservation “I need C units of time.. out of every T units.”
16
NUS.SOC.CS5248 Ooi Wei Tsang 16 Some Issues “I need C units of time, out of every T units.”
17
NUS.SOC.CS5248 Ooi Wei Tsang 17 Effects of T and C
18
NUS.SOC.CS5248 Ooi Wei Tsang 18 Effects of T and C
19
NUS.SOC.CS5248 Ooi Wei Tsang 19 Schedulability Theorems Rate Monotonic Scheduler Earliest Deadline First
20
NUS.SOC.CS5248 Ooi Wei Tsang 20 Assumptions programs are periodic computation time is constant zero context switch time programs are independent
21
NUS.SOC.CS5248 Ooi Wei Tsang 21 Rialto Scheduler CPU Reservations and Time Contraints: Efficient and Predictable Scheduling of Independent Activities, M. Jones, D. Rosu and M. Rosu
22
NUS.SOC.CS5248 Ooi Wei Tsang 22 Why Rialto? Provide CPU reservation Enable deadlines Co-exists with best-effort apps
23
NUS.SOC.CS5248 Ooi Wei Tsang 23 Overview input: a set of tasks and their reservation pre-compute a scheduling graph schedule tasks based on scheduling graph
24
TaskABCDEF Amount C 432115 Period T 201040201040 EBCA EBFD EBA EBD
25
TaskABCDEF Amount 432115 Period 201040201040 C F A D EB
26
NUS.SOC.CS5248 Ooi Wei Tsang 26 Advantages Only need to make new scheduling decisions when new task is added
27
NUS.SOC.CS5248 Ooi Wei Tsang 27 Computing Scheduling Graph Input: A set of tasks with their reservations Output: A scheduling graph if feasible
28
NUS.SOC.CS5248 Ooi Wei Tsang 28 Many Possible Solutions C F A D EB F C A D EB
29
TaskABCDEF Amount 432115 Period 201040201040 C F F A D EB
30
NUS.SOC.CS5248 Ooi 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
31
NUS.SOC.CS5248 Ooi Wei Tsang 31 Life is Tough.. NP-Hard
32
NUS.SOC.CS5248 Ooi Wei Tsang 32 Heuristic 10
33
5 5 5 F TaskABCDEF Amount 432115 Period 201040201040
34
6 1 6 6 1 6 1 F B+E TaskABCDEF Amount 432115 Period 201040201040
35
4 1 1 1 1 1 1 F B+E A+D C TaskABCDEF Amount 432115 Period 201040201040
36
NUS.SOC.CS5248 Ooi Wei Tsang 36 Time Constraint “I need to run the following code, that takes 30ms, 100ms from now, and the deadline is (now+180ms).”
37
NUS.SOC.CS5248 Ooi Wei Tsang 37 Pseudocode can = begin_constraint(start_time, deadline, estimate) if can schedule then do work else adapt time_taken = end_constraint()
38
NUS.SOC.CS5248 Ooi Wei Tsang 38 Scheduling Constraints C F F A D EB
39
NUS.SOC.CS5248 Ooi Wei Tsang 39 Advantages Only need to make new scheduling decisions when new task is added Feasibility of time constraint can be predicted accurately
40
NUS.SOC.CS5248 Ooi Wei Tsang 40 Running Unreserved Task C F F A D EB
41
NUS.SOC.CS5248 Ooi Wei Tsang 41 Media Player on Rialto/NT
42
NUS.SOC.CS5248 Ooi Wei Tsang 42 Look inside NT Scheduler Scheduling unit : Thread Priority level: 1-15, 16-31 rt 24 high 13 normal 8 idle 4
43
NUS.SOC.CS5248 Ooi Wei Tsang 43 Priority Boosting Example: Priority +6 after awaken by keyboard input
44
NUS.SOC.CS5248 Ooi Wei Tsang 44 Anti-Starvation If hasn’t run for 3 seconds Boost priority to 14 Avoid “Priority Inversion”
45
NUS.SOC.CS5248 Ooi Wei Tsang 45 Mars Pathfinder
46
NUS.SOC.CS5248 Ooi Wei Tsang 46 Rialto/NT NT Scheduler Rialto C F F A D EB Boost Priority to 30
47
NUS.SOC.CS5248 Ooi Wei Tsang 47 Win Media Player 6.4 PeriodPriorityThread 1024Kernel Mixer 458GUI 10015Timer 1009MP3 Decoder 5008Unknown 20008Disk Reader
48
NUS.SOC.CS5248 Ooi Wei Tsang 48 Experiment 1 WMP running alone PeriodPriorityThread 1024Kernel Mixer 458GUI 10015Timer 1009MP3 Decoder 5008Unknown 20008Disk Reader
49
NUS.SOC.CS5248 Ooi Wei Tsang 49 Experiment 2 WMP running with priority 8 competitor PeriodPriorityThread 1024Kernel Mixer 458GUI 10015Timer 1009MP3 Decoder 5008Unknown 20008Disk Reader
50
NUS.SOC.CS5248 Ooi Wei Tsang 50 Experiment 3 WMP running with priority 10 competitor PeriodPriorityThread 1024Kernel Mixer 458GUI 10015Timer 1009MP3 Decoder 5008Unknown 20008Disk Reader
51
NUS.SOC.CS5248 Ooi Wei Tsang 51 Experiment 5 WMP running with priority 10 competitor PeriodPriorityReservationThread 1024Kernel Mixer 458GUI 10015Timer 1009 40/1024 MP3 Decoder 5008Unknown 20008Disk Reader
52
NUS.SOC.CS5248 Ooi Wei Tsang 52 Experiment 6 WMP running with priority 10 competitor PeriodPriorityReservationThread 1024 1/16 Kernel Mixer 458GUI 10015Timer 1009 40/1024 MP3 Decoder 5008Unknown 20008Disk Reader
53
NUS.SOC.CS5248 Ooi Wei Tsang 53 Experiment 7 WMP running with priority 10 competitor PeriodPriorityReservationThread 1024Kernel Mixer 458GUI 10015Timer 1009 20/512 MP3 Decoder 5008Unknown 20008Disk Reader
54
NUS.SOC.CS5248 Ooi Wei Tsang 54 Summary
55
NUS.SOC.CS5248 Ooi Wei Tsang 55 CPU Scheduling With guarantee percentage of CPU time task with deadline Algorithms Rate-monotonic EDF Rialto
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.