University of New Mexico
1
CPU Virtualization: Scheduling Intro
- Prof. Patrick G. Bridges
CPU Virtualization: Scheduling Intro Prof. Patrick G. Bridges 1 - - PowerPoint PPT Presentation
University of New Mexico CPU Virtualization: Scheduling Intro Prof. Patrick G. Bridges 1 University of New Mexico Scheduling: Introduction Workload assumptions: 1. Each job runs for the same amount of time. 2. All jobs arrive at the same
University of New Mexico
1
University of New Mexico
2
Workload assumptions:
University of New Mexico
3
Performance metric: Turnaround time
Another metric is fairness.
Role of scheduler metrics
University of New Mexico
4
First Come, First Served (FCFS)
Example:
20 40 60 80 100 120
Time (Second) A B C
𝑩𝒘𝒇𝒔𝒃𝒉𝒇 𝒖𝒗𝒔𝒐𝒃𝒔𝒑𝒗𝒐𝒆 𝒖𝒋𝒏𝒇 = 𝟐𝟏 + 𝟑𝟏 + 𝟒𝟏 𝟒 = 𝟑𝟏 𝒕𝒇𝒅
University of New Mexico
5
Let’s relax assumption 1: Each job no longer runs for the
Example:
20 40 60 80 100 120
Time (Second) A B C
𝑩𝒘𝒇𝒔𝒃𝒉𝒇 𝒖𝒗𝒔𝒐𝒃𝒔𝒑𝒗𝒐𝒆 𝒖𝒋𝒏𝒇 = 𝟐𝟏𝟏 + 𝟐𝟐𝟏 + 𝟐𝟑𝟏 𝟒 = 𝟐𝟐𝟏 𝒕𝒇𝒅
University of New Mexico
6
Run the shortest job first, then the next shortest, and so
Example:
20 40 60 80 100 120
Time (Second) A B C
𝑩𝒘𝒇𝒔𝒃𝒉𝒇 𝒖𝒗𝒔𝒐𝒃𝒔𝒑𝒗𝒐𝒆 𝒖𝒋𝒏𝒇 = 𝟐𝟏 + 𝟑𝟏 + 𝟐𝟑𝟏 𝟒 = 𝟔𝟏 𝒕𝒇𝒅
University of New Mexico
7
Let’s relax assumption 2: Jobs can arrive at any time. Example:
𝑩𝒘𝒇𝒔𝒃𝒉𝒇 𝒖𝒗𝒔𝒐𝒃𝒔𝒑𝒗𝒐𝒆 𝒖𝒋𝒏𝒇 = 𝟐𝟏𝟏 + 𝟐𝟐𝟏 − 𝟐𝟏 + (𝟐𝟑𝟏 − 𝟐𝟏) 𝟒 = 𝟐𝟏𝟒. 𝟒𝟒 𝒕𝒇𝒅
20 40 60 80 100 120
Time (Second) A B C [B,C arrive]
University of New Mexico
8
Add preemption to SJF
A new job enters the system:
University of New Mexico
9
Example:
𝑩𝒘𝒇𝒔𝒃𝒉𝒇 𝒖𝒗𝒔𝒐𝒃𝒔𝒑𝒗𝒐𝒆 𝒖𝒋𝒏𝒇 = (𝟐𝟑𝟏 − 𝟏) + 𝟑𝟏 − 𝟐𝟏 + (𝟒𝟏 − 𝟐𝟏) 𝟒 = 𝟔𝟏 𝒕𝒇𝒅
20 40 60 80 100 120
Time (Second) A B C [B,C arrive] A
University of New Mexico
10
The time from when the job arrives to the first time it is
University of New Mexico
11
Time slicing Scheduling
▪ Time slice is sometimes called a scheduling quantum.
University of New Mexico
12
A, B and C arrive at the same time. They each wish to run for 5 seconds.
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𝑡𝑓𝑑
University of New Mexico
13
The shorter time slice
The longer time slice
University of New Mexico
14
Let’s relax assumption 3: All programs perform I/O Example:
▪ I/Os each take 10ms
University of New Mexico
15
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
University of New Mexico
16
When a job initiates an I/O request.
When the I/O completes
University of New Mexico
17
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.