Escolar Documentos
Profissional Documentos
Cultura Documentos
CS 537
Lecture 5
Scheduling
Michael Swift
1)
Types of Resources
OS management: allocation
3)
Preemptible resources
OS management: scheduling
Scheduling
CPU Scheduler
Dispatcher
Dispatcher module gives control of the CPU to the
process selected by the short-term scheduler; this
involves:
switching context
switching to user mode
jumping to the proper location in the user program to
restart that program
Process Model
Workload contains collection of jobs (processes)
Matrix multiply
I/O-bound: Short CPU bursts
emacs
emacs
I/O burst = process idle, switch to another for free
Problem: dont know jobs type before running
Scheduling Goals
Minimize overhead
Maximize fairness
All jobs get same amount of CPU over some time interval
Scheduler Non-goals
Gantt Chart
Example:
Time!
11
0!
A!
B!
10!
C!
12!
16!
12
First-Come-First-Served (FCFS)
FCFS Discussion
Advantage: Very simple implementation
Disadvantage
Time!
Job
Arrival
CPU
burst
10
0!
B!
10!
C!
12!
CPU!
Disk!
16!
13
B! C! D!
B! C! D!
Idle!
A!
Idle!
A!
B! C! D!
B! C! D!
14
Time!
Shortest-Job-First (SJF)
SJF Discussion
Advantages
Provably optimal for minimizing average wait time (with no
preemption)
Moving shorter job before longer job improves waiting time of
short job more than it harms waiting time of long job
Time!
Job
Arrival
CPU
burst
10
0!
B!
2!
C!
Disadvantages
Average wait:!
Average turnaround:!
6!
A!
16!15
16
Shortest-Time-to-Completion-First (STCF
or SCTF)
Round-Robin (RR)
Arrival
CPU
burst
Job
Arrival
CPU
burst
10
Time
A B
0 1
5
D
12
C
17
A
10
26
SJF
C
17
Average wait:!
26
17
C A
Time
18
RR Discussion
RR Time-Slice
Advantages
Disadvantages
Poor average waiting time with similar job lengths
CPU!
Disk
Idle
Idle
Time
19
20
Priority-Based
Scheduling Algorithms
Advantages
Static priorities work well for real time systems
Dynamic priorities work well for general workloads
Disadvantages
interactive processes
CPU-bound processes
batch jobs
system processes
student programs
21
22
Scheduling Algorithms
Highest priority
Quantum = 2
Quantum = 4
Quantum = 8
Number of queues
Scheduling algorithm within each queue
When to upgrade and downgrade a job
FCFS
Lowest priority
25
26
UNIX Scheduling
A Multi-level System
high
priority
Goals:
reward interactive behavior over CPU hogs
low
timeslice
high
28
Solaris Schedulers
Table Example
Scheduling classes
Time sharing dynamically alters priorities and timeslices higher
priority indicates lower timeslice, more responsive but less time to
respond.
Fixed priority priorities dont change, good for real time. Is
preemptive
Fair share doesnt assign priority, but shares CPU equally among
processes at this level
29
Priority
Quantum
(ms)
Quantum expired
Prio
MaxWait
Wait
Level
200
50
10000
200
50
10
10
160
51
15
15
160
51
20
20
120
10
52
25
25
120
15
52
30
30
80
20
53
35
35
80
25
54
40
40
40
30
55
45
45
40
35
56
50
50
40
40
58
55
55
40
45
58
59
59
20
49
59
59
9/23/09
30