- 7. Scheduling: Introduction
Operating System: Three Easy Pieces
1 Youjip Won
7. Scheduling: Introduction Operating System: Three Easy Pieces 1 - - PowerPoint PPT Presentation
7. Scheduling: Introduction Operating System: Three Easy Pieces 1 Youjip Won Scheduling: Introduction Workload assumptions: 1. Each job runs for the same amount of time. 2. All jobs arrive at the same time. 3. All jobs only use the CPU
Operating System: Three Easy Pieces
1 Youjip Won
Workload assumptions:
2 Youjip Won
Performance metric: Turnaround time
Another metric is fairness.
3 Youjip Won
First Come, First Served (FCFS)
Example:
4 Youjip Won
20 40 60 80 100 120
Time (Second) A B C
𝑩𝒘𝒇𝒔𝒃𝒉𝒇 𝒖𝒗𝒔𝒐𝒃𝒔𝒑𝒗𝒐𝒆 𝒖𝒋𝒏𝒇 = 𝟐𝟏 + 𝟑𝟏 + 𝟒𝟏 𝟒 = 𝟑𝟏 𝒕𝒇𝒅
Let’s relax assumption 1: Each job no longer runs for the same
Example:
5 Youjip Won
20 40 60 80 100 120
Time (Second) A B C
𝑩𝒘𝒇𝒔𝒃𝒉𝒇 𝒖𝒗𝒔𝒐𝒃𝒔𝒑𝒗𝒐𝒆 𝒖𝒋𝒏𝒇 = 𝟐𝟏𝟏 + 𝟐𝟐𝟏 + 𝟐𝟑𝟏 𝟒 = 𝟐𝟐𝟏 𝒕𝒇𝒅
Run the shortest job first, then the next shortest, and so on
Example:
6 Youjip Won
20 40 60 80 100 120
Time (Second) A B C
𝑩𝒘𝒇𝒔𝒃𝒉𝒇 𝒖𝒗𝒔𝒐𝒃𝒔𝒑𝒗𝒐𝒆 𝒖𝒋𝒏𝒇 = 𝟐𝟏 + 𝟑𝟏 + 𝟐𝟑𝟏 𝟒 = 𝟔𝟏 𝒕𝒇𝒅
Let’s relax assumption 2: Jobs can arrive at any time. Example:
7 Youjip Won
𝑩𝒘𝒇𝒔𝒃𝒉𝒇 𝒖𝒗𝒔𝒐𝒃𝒔𝒑𝒗𝒐𝒆 𝒖𝒋𝒏𝒇 = 𝟐𝟏𝟏 + 𝟐𝟐𝟏 − 𝟐𝟏 + (𝟐𝟑𝟏 − 𝟐𝟏) 𝟒 = 𝟐𝟏𝟒. 𝟒𝟒 𝒕𝒇𝒅
20 40 60 80 100 120
Time (Second) A B C [B,C arrive]
Add preemption to SJF
A new job enters the system:
8 Youjip Won
Example:
9 Youjip Won
𝑩𝒘𝒇𝒔𝒃𝒉𝒇 𝒖𝒗𝒔𝒐𝒃𝒔𝒑𝒗𝒐𝒆 𝒖𝒋𝒏𝒇 = (𝟐𝟑𝟏 − 𝟏) + 𝟑𝟏 − 𝟐𝟏 + (𝟒𝟏 − 𝟐𝟏) 𝟒 = 𝟔𝟏 𝒕𝒇𝒅
20 40 60 80 100 120
Time (Second) A B C [B,C arrive] A
The time from when the job arrives to the first time it is scheduled.
10 Youjip Won
Time slicing Scheduling
Time slice is sometimes called a scheduling quantum.
11 Youjip Won
A, B and C arrive at the same time. They each wish to run for 5 seconds.
12 Youjip Won
5 10 15 20 25 30 Time (Second)
A B C SJF (Bad for Response Time)
5 10 15 20 25 30 Time (Second)
A B C RR with a time-slice of 1sec (Good for Response Time) A B CA B CA B CA B C
𝑈
𝑏𝑤𝑓𝑠𝑏𝑓 𝑠𝑓𝑡𝑞𝑝𝑜𝑡𝑓 = 0 + 5 + 10
3 = 5𝑡𝑓𝑑 𝑈
𝑏𝑤𝑓𝑠𝑏𝑓 𝑠𝑓𝑡𝑞𝑝𝑜𝑡𝑓 = 0 + 1 + 2
3 = 1𝑡𝑓𝑑
The shorter time slice
The longer time slice
13 Youjip Won
Let’s relax assumption 3: All programs perform I/O Example:
I/Os each take 10ms
14 Youjip Won
15 Youjip Won
20 40 60 80 100 120 Time (msec)
A B Poor Use of Resources
140
A A A A B B B B
20 40 60 80 100 120 Time (msec)
A B Overlap Allows Better Use of Resources
140
A A A A B B B B
When a job initiates an I/O request.
When the I/O completes
16 Youjip Won
Disclaimer: This lecture slide set was initially developed for Operating System course in Computer Science Dept. at Hanyang University. This lecture slide set is for OSTEP book written by Remzi and Andrea at University of Wisconsin.
17 Youjip Won