9 - OS - CH09 - Uniprocessor Scheduling - OS8e
9 - OS - CH09 - Uniprocessor Scheduling - OS8e
Operating
Systems:
Internals
and Chapter 9
Design Uniprocessor
Principles
Scheduling
Eighth Edition
By William Stallings
Table 9.1
Types of Scheduling
١
١٦/٠١/١٤٣٨
Processor Scheduling
Aim is to assign processes to be executed by the
processor in a way that meets system objectives, such as
response time, throughput, and processor efficiency
Broken down into three separate functions:
medium
long term short term
term
scheduling scheduling
scheduling
New
Long-term
Long-term scheduling
scheduling
Ready/
Suspend
Ready Running Exit
Medium-term Short-term
scheduling scheduling
Blocked/
Blocked
Suspend
Medium-term
scheduling
٢
١٦/٠١/١٤٣٨
Running
Ready
Blocked
Short Term
Blocked,
Suspend
Ready,
Suspend
Medium Term
Long Term
New Exit
Long-term Time-out
scheduling
Medium-term
scheduling
Interactive Ready, Suspend Queue
users
Medium-term
scheduling
Blocked Queue
Event Event Wait
Occurs
٣
١٦/٠١/١٤٣٨
Long--Term Scheduler
Long
Determines which Creates processes
programs are admitted to from the queue when
it can, but must
the system for processing decide:
Medium--Term Scheduling
Medium
Part of the swapping function
Swapping-in decisions are based on the need to manage
the degree of multiprogramming
considers the memory requirements of the
swapped-out processes
٤
١٦/٠١/١٤٣٨
Short--Term Scheduling
Short
Known as the dispatcher
Invoked when an event occurs that may lead to the blocking of the
current process or that may provide an opportunity to preempt a
currently running process in favor of another
Examples:
• Clock interrupts
• I/O interrupts
• Operating system calls
• Signals (e.g., semaphores)
٥
١٦/٠١/١٤٣٨
Non-performance
Performance-related
related
easily hard to
quantitative qualitative
measured measure
٦
١٦/٠١/١٤٣٨
RQ0 Release
Dispatch
Processor
RQ1
Admit
RQn
Preemption
Event Wait
Event
occurs Blocked Queue
Round
FCFS SPN SRT HRRN Feedback
robin
Selection w +s
max[w] constant min[s] min[s – e] max (see text)
function s
Decision
mode
Non- Preemptive
(at time
Non- Preemptive
(at arrival)
Non- Preemptive
(at time Table 9.3
preemptive quantum) preemptive preemptive quantum)
May be
Through- Not low if Not
Characteristic
quantum High High High s of Various
Put emphasized emphasized
is too
small Scheduling
May be Policies
high,
Provides Provides
especially if
good good Provides
there is a
Response response response good Provides good Not
large response
time time for time for response time emphasized
variance in time
short short
process
processes processes
execution
times
Overhead Minimum Minimum Can be high Can be high Can be high Can be high
Penalizes
short
Penalizes Penalizes May favor
Effect on processes; Fair
long long Good balance I/O bound
processes penalizes treatment
processes processes processes
I/O bound
processes (Table can be found
on page 405 in
Starvation No No Possible Possible No Possible textbook)
٧
١٦/٠١/١٤٣٨
٨
١٦/٠١/١٤٣٨
Nonpreemptive Preemptive
currently running process
may be interrupted and
once a process is in the
moved to ready state by
running state, it will
the OS
continue until it terminates
or blocks itself for I/O preemption may occur
when new process arrives,
on an interrupt, or
periodically
Table 9.4
Process Scheduling Example
٩
١٦/٠١/١٤٣٨
0 5 10 15 20
A
First-Come-First B
Served (FCFS) C
D
E
A
Round-Robin B
(RR), q = 1 C
D
E
A
Round-Robin B
(RR), q = 4 C
D
E
A
Shortest Process B
Next (SPN) C
D
E
A
Shortest Remaining B
Time (SRT) C
D
E
A
Highest Response B
Ratio Next (HRRN) C
D
E
A
Feedback B
q=1 C
D
E
A
Feedback B
q = 2i C
D
E
0 5 10 15 20
Figure 9.5 A Comparison of Scheduling Policies
١٠
١٦/٠١/١٤٣٨
Time
Quantum
q
١١
١٦/٠١/١٤٣٨
Process A B C D E
Arrival Time 0 2 4 6 8
Service Time (Ts) 3 6 4 5 2 Mean
FCFS
Finish Time 3 9 13 18 20
Turnaround Time (Tr) 3 7 9 12 12 8.60
Tr/Ts 1.00 1.17 2.25 2.40 6.00 2.56
Finish Time 4
RR q = 1
18 17 20 15
Table 9.5
Turnaround Time (Tr) 4 16 13 14 7 10.80
Tr/Ts 1.33 2.67 3.25 2.80 3.50 2.71
Finish Time 3
RR q = 4
17 11 20 19
A Comparison
Turnaround Time (Tr) 3 15 7 14 11 10.00
Tr/Ts 1.00 2.5 1.75 2.80 5.50 2.71 of Scheduling
SPN
Finish Time
Turnaround Time (Tr)
3
3
9
7
15
11
20
14
11
3 7.60
Policies
Tr/Ts 1.00 1.17 2.75 2.80 1.50 1.84
SRT
Finish Time 3 15 8 20 10
Turnaround Time (Tr) 3 13 4 14 2 7.20
Tr/Ts 1.00 2.17 1.00 2.80 1.00 1.59
HRRN
Finish Time 3 9 13 20 15
Turnaround Time (Tr) 3 7 9 14 7 8.00
Tr/Ts 1.00 1.17 2.25 2.80 3.5 2.14
FB q = 1
Finish Time 4 20 16 19 11
Turnaround Time (Tr) 4 18 12 13 3 10.00
Tr/Ts 1.33 3.00 3.00 2.60 1.5 2.29
FB q = 2i
Finish Time 4 17 18 20 14
Turnaround Time (Tr) 4 15 14 14 6 10.60 (Table is on page 408 in textbook)
Tr/Ts 1.33 2.50 3.50 2.80 3.00 2.63
Time-out
Ready Queue
Admit Dispatch Release
Processor
Auxiliary Queue
١٢
١٦/٠١/١٤٣٨
١٣
١٦/٠١/١٤٣٨
١٤
١٦/٠١/١٤٣٨
١٥
١٦/٠١/١٤٣٨
RQ0 Release
Admit
Processor
RQ1 Release
Processor
RQn Release
Processor
Performance Comparison
Any scheduling discipline that chooses the next item to be served
independent of service time obeys the relationship:
١٦
١٦/٠١/١٤٣٨
Table 9.6
Formulas
for Single-
Server
Queues
with Two
Priority
Categories
١٧
١٦/٠١/١٤٣٨
١٨
١٦/٠١/١٤٣٨
100
FCFS
Normalized turnaround time
10
HRRN FB
RR (q = 1) SRT
RR (q = 1)
SPN
SPN
HRRN
FB FCFS
SRT
1
0 10 20 30 40 50 60 70 80 90 100
Percentile of time required
RR
10 (q = 1)
FB SPN
9
8
HRRN
7
6
Wait time
5
FCFS
4 FCFS
3
RR (q = 1)
2
HRRN
SPN
1
SRT
FB
0
0 10 20 30 40 50 60 70 80 90 100
١٩
١٦/٠١/١٤٣٨
Fair--Share Scheduling
Fair
Scheduling decisions based on the process sets
Each user is assigned a share of the processor
Objective is to monitor usage to give fewer
resources to users who have had more than their
fair share and more to those who have had less
than their fair share
٢٠
١٦/٠١/١٤٣٨
Scheduling Formula
٢١
١٦/٠١/١٤٣٨
Bands
Swapper
Used to optimize access
to block devices and to
allow the operating Block I/O
system to respond device control
quickly to system calls
File
In decreasing order of manipulation
priority, the bands are:
Character I/O
device control
User
processes
٢٢
١٦/٠١/١٤٣٨
Summary
Types of processor Scheduling algorithms
scheduling Short-term
Long-term scheduling criteria
scheduling The use of
Medium-term priorities
scheduling Alternative
Short-term scheduling policies
scheduling Performance
comparison
Traditional UNIX Fair-share
scheduling scheduling
٢٣