Upload
naveen-kumar
View
229
Download
0
Embed Size (px)
Citation preview
8/8/2019 09 Uniprocessor Scheduling
1/39
1
2005mauriziopizzonia-sistemioperativia.a.
2004-2005
Uniprocessor Scheduling
8/8/2019 09 Uniprocessor Scheduling
2/39
2005mauriziopizzonia-sistemioperativia.a.
2004-2005
2
types of scheduling in OS
8/8/2019 09 Uniprocessor Scheduling
3/39
2005mauriziopizzonia-sistemioperativia.a.
2004-2005
3
Long-Term Scheduling
Determines which programs areadmitted to the system forprocessing
Controls the degree ofmultiprogramming
More processes, smaller percentage
of time each process is executed
8/8/2019 09 Uniprocessor Scheduling
4/39
2005mauriziopizzonia-sistemioperativia.a.
2004-2005
4
Medium-Term Scheduling
i.e. swapping Based on the need to manage the
degree of multiprogramming
8/8/2019 09 Uniprocessor Scheduling
5/39
2005mauriziopizzonia-sistemioperativia.a.
2004-2005
5
Short-Term (cpu) Scheduling a cpu scheduling policy decides for each cpu...
which process should be executed how long it will be executed
implemented in the dispatcher, a.k.a. scheduler the scheduler executes very frequently
Invoked when an event occurs
Timer interrupts
I/O interrupts traps
Operating system calls
8/8/2019 09 Uniprocessor Scheduling
6/39
2005mauriziopizzonia-sistemioperativia.a.
2004-2005
6
process states
h d li d t t
8/8/2019 09 Uniprocessor Scheduling
7/39
2005mauriziopizzonia-sistemioperativia.a.
2004-2005
7
scheduling and process statetransitions
8/8/2019 09 Uniprocessor Scheduling
8/39
2005mauriziopizzonia-sistemioperativia.a.
2004-2005
8
levels ofscheduling
8/8/2019 09 Uniprocessor Scheduling
9/39
9
2005mauriziopizzonia-sistemi
operativia.a.
2004-2005
short term cpu scheduling
8/8/2019 09 Uniprocessor Scheduling
10/39
2005mauriziopizzonia-sistemi
operativia.a.
2004-2005
10
queue
1
s
w+s = r= residence time
response time
turnaround time
s = service time
(so far, at a given instant: e)w= waiting time
schduling(or dispatching)
policy
(statistically)
8/8/2019 09 Uniprocessor Scheduling
11/39
2005mauriziopizzonia-sistemi
operativia.a.
2004-2005
11
Optimality Criteria
Performance-related Quantitative
Measurable such as response time
and throughput
other
predictability fairness
ecc.
8/8/2019 09 Uniprocessor Scheduling
12/39
2005mauriziopizzonia-sistemi
operativia.a.
2004-2005
12
Optimality Criteria
User-oriented Response Time
Elapsed time from submission to begin of
the service. Normalized Response Time w.r.t.service time, that is (w+s)/s
System-oriented Effective and efficient utilization of the
processor
8/8/2019 09 Uniprocessor Scheduling
13/39
2005mauriziopizzonia-sistemi
operativia.a.
2004-2005
13
optimality criteria
8/8/2019 09 Uniprocessor Scheduling
14/39
2005mauriziopizzonia-sistemi
operativia.a.
2004-2005
14
scheduling criteria
8/8/2019 09 Uniprocessor Scheduling
15/39
2005ma
uriziopizzonia-sistemi
operativia.a.
2004-2005
15
scheduling queuing diagram
8/8/2019 09 Uniprocessor Scheduling
16/39
2005ma
uriziopizzonia-sistemi
operativia.a.
2004-2005
16
Priorities
a priority is assigned to each process a ready process queue for each priority Scheduler will always choose a process of
higher priority over one of lower priority Lower-priority may suffer starvation
Allow a process to change its priority based on
its age or execution history
8/8/2019 09 Uniprocessor Scheduling
17/39
2005ma
uriziopizzonia-sistemi
operativia.a.
2004-2005
17
Decision Mode
Nonpreemptive Once a process is in the running state, it will
continue until it terminates or blocks itself forI/O
Preemptive Currently running process may be interrupted
and moved to the Ready state by theoperating system
Allows for better service since any oneprocess cannot monopolize the processor forvery long
8/8/2019 09 Uniprocessor Scheduling
18/39
2005ma
uriziopizzonia-sistemi
operativia.a.
2004-2005
18
priority queuing and preemption
8/8/2019 09 Uniprocessor Scheduling
19/39
2005ma
uriziopizzonia-sistemi
operativia.a.
2004-2005
19
Process Scheduling Example
arrival time: when the process enter theready queue
service time: the process virtual time elapsed
till the next blocking operation
8/8/2019 09 Uniprocessor Scheduling
20/39
2005ma
uriziopizzonia-sistemi
operativia.a.
2004-2005
20
First-Come-First-Served
(FCFS)
When the current process ceases toexecute, the oldest process in theReady queue is selected
8/8/2019 09 Uniprocessor Scheduling
21/39
2005ma
uriziopizzonia-sistemi
operativia.a.
2004-2005
21
First-Come-First-Served(FCFS)
A short process may have to wait avery long time before it can execute
Favors CPU-bound processes
I/O processes have to wait until CPU-bound process completes
Fi t C Fi t S d
8/8/2019 09 Uniprocessor Scheduling
22/39
2005ma
uriziopizzonia-sistemi
operativia.a.
2004-2005
22
First-Come-First-Served(FCFS)
Tr/ Ts(Tr)
8/8/2019 09 Uniprocessor Scheduling
23/39
2005ma
uriziopizzonia-sistemi
operativia.a.
2004-2005
23
Round-Robin
(RR), q=1
Uses preemption based on a clock An amount of time (quantumq) is
determined that allows each processto use the processor for that length of
time
8/8/2019 09 Uniprocessor Scheduling
24/39
2005ma
uriziopizzonia-sistemi
operativia.a.
2004-2005
24
Round-Robin
Clock interrupt is generated atperiodic intervals
When an interrupt occurs, the
currently running process is placedin the read queue (preempted) Next ready job is selected
a.k.a. time slicing
ff f i f i i
8/8/2019 09 Uniprocessor Scheduling
25/39
2005ma
uriziopizzonia-sistemi
operativia.a.
2004-2005
25
effect of size of preemption timequantum
ff t f i f ti ti
8/8/2019 09 Uniprocessor Scheduling
26/39
2005ma
uriziopizzonia-sistemi
operativia.a.
2004-2005
26
effect of size of preemption timequantum
8/8/2019 09 Uniprocessor Scheduling
27/39
2005ma
uriziopizzonia-sistemi
operativia.a.
2004-2005
27
unfairness of RR
I/O-bound processes usually release cpubefore expiration of their quantum
cpu-bound processes run for the whole
quantum
RR prefers cpu-bound processes
8/8/2019 09 Uniprocessor Scheduling
28/39
2005ma
uriziopizzonia-sistemi
operativia.a.
2004-2005
28
virtual round robin
aux queueis preferredover readyqueue
processesfrom auxqueue run
for theirremainingquantum
fraction
Sh t t P
8/8/2019 09 Uniprocessor Scheduling
29/39
2005ma
uriziopizzonia-sistemi
operativia.a.
2004-200
5
29
Shortest ProcessNext (SPN, SJF)
Nonpreemptive policy, optimal w.r.t. min total waiting time
need to know future! approximated. expected processing time to the next blocking i/o operation
process with shortest expected processing time is selectednext
8/8/2019 09 Uniprocessor Scheduling
30/39
2005ma
uriziopizzonia-sistemi
operativia.a.
2004-200
5
30
Shortest Process Next
Predictability of longer processes isreduced
Possibility of starvation for longer
processes exstimation of time length of the
next cpu-bust may be done by
exponential averaging
Sn1=Tn1Sn
( 0,1 ]
8/8/2019 09 Uniprocessor Scheduling
31/39
2005ma
uriziopizzonia-sistemioperativia.a.
2004-200
5
31
ShortestRemaining
Time (SRT)
Preemptive version of shortestprocess next policy
Must estimate processing time
8/8/2019 09 Uniprocessor Scheduling
32/39
2005ma
uriziopizzonia-sistemioperativia.a.
2004-200
5
32
Highest ResponseRatio Next (HRRN)
non preemptive choose next process with the greatest ratio
time spent waiting + expected service time
expected service time
HRRNC, D, E=? HRRND, E=?
=ws
s
8/8/2019 09 Uniprocessor Scheduling
33/39
2005ma
uriziopizzonia-sistemioperativia.a.
2004-200
5
33
Highest ResponseRatio Next (HRRN)
HRRNC=(5+4)/4=2.25
HRRND=(3+5)/5=1.6
HRRNE=(1+2)/2=1.5
HRRND=(5+2)/2=3.5
HRRNE=(7+5)/2=6
ws
s
8/8/2019 09 Uniprocessor Scheduling
34/39
2005ma
uriziopizzonia-sistemioperativia.a.
2004-200
5
34
a first comparison
FCFS penalize i/o-bound processes
RR
penalize i/o-bound processes
VRR
fair, do not emphasize response time of i/o-bound
processes
SPN, SRT, HRRN
need service time prediction
8/8/2019 09 Uniprocessor Scheduling
35/39
2005ma
uriziopizzonia-sistemioperativia.a.
2004-200
5
35
feedback
does not needservice timeestimation
preemptive as inRR (q=1 or q=2i)
demotesprocesses at eachexpired timequantum intolower priority
queues
8/8/2019 09 Uniprocessor Scheduling
36/39
2005ma
uriziopizzonia-sistemioperativia.a.
2004-200
5
36
feedback: varianti
un processo scala di priorita'... sempre quando scade il suo quanto di tempo
oppure
quando scade il quanto e c'e` una altro processonella sua coda
oppure
quando scade il quanto e c'e` almeno una altroprocesso nel sistema (Stallings)
8/8/2019 09 Uniprocessor Scheduling
37/39
2005ma
uriziopizzonia-sistemioperativia.a.
2004-200
5
37
Feedback
0 1
42 30 1 542 30 142 30 1 5
0 1
0 120 1
20 1 20 10 1
8/8/2019 09 Uniprocessor Scheduling
38/39
2005ma
uriziopizzonia-sistemioperativia.a.
2004-200
5
38
8/8/2019 09 Uniprocessor Scheduling
39/39
2005ma
uriziopizzonia-sistemioperativia.a.
2004-200
5
39
simulation results