CPU Scheduling
1
Disclaimer: some slides are adopted from book authors’ and Dr. Kulkarni’s slides with permission
CPU Scheduling Disclaimer: some slides are adopted from book authors - - PowerPoint PPT Presentation
CPU Scheduling Disclaimer: some slides are adopted from book authors and Dr. Kulkarnis slides with permission 1 Recap Deadlock prevention Break any of four deadlock conditions Mutual exclusion, no preemption, hold & wait,
1
Disclaimer: some slides are adopted from book authors’ and Dr. Kulkarni’s slides with permission
dependency
2
3
4
Process Arrival Time Burst Time P1 8 P2 1 4 P3 2 9 P4 3 5
P
1
P2 P4 P1 P3
1 5 10 17 26
P1 P2 P3 P4
5
6
7
Process Burst Times P1 24 P2 3 P3 3 P1 P2 P3 P1 P1 P1 P1 P1 4 7 10 14 18 22 26 30
8
9
Process Burst Times P1 24 P2 3 P3 3 P1 P2 P3 P1 P2 P1 P1 P3 P1 2 4 6 8 9 12 14 10 30
10
11
Compute I/O I/O
12
…
I/O I/O
I/O
…
I/O
I/O
– Run to completion in order of arrival – Pros: simple, low overhead, good for batch jobs – Cons: short jobs can stuck behind the long ones
– FCFS with preemption. Cycle after a fixed time quantum – Pros: better interactivity (optimize response time) – Cons: performance is dependent on the quantum size
– Shorted job (or shortest remaining job) first – Pros: optimal average waiting time (turn-around time) – Cons: you need to know the future, long jobs can be starved by short jobs
13
14
15
16
17
18
19
20
5 6 8 10
21
9 6 8 10
22 Figure source: M. Tim Jones, “Inside the Linux 2.6 Completely Fair Scheduler”, IBM developerWorks
23
24 [*] Robert Leibinger, “Software Architectures for Advanced Driver Assistance Systems (ADAS)”, OSPERT’15 keynote
25
26
27
CFS (sched/fair.c) Real-time (sched/rt.c)
28
29
Core1 Core2 Core3 Core4 DRAM
30
CPU1 CPU2 CPU3 CPU4 HW OS RunQueue tasks
31
CPU1 CPU2 CPU3 CPU4 HW OS
RunQueue
tasks
RunQueue
tasks
RunQueue
tasks
RunQueue
tasks
32
33
Core1 Core2 Core3 Core4 LLC LLC
34
– Migration overhead – Shared hardware resources (cache, dram, etc) – Core architecture heterogeneity (big cores vs. small cores) – …
35
36
37