Scheduling - cs.anu.edu.au
Transcript of Scheduling - cs.anu.edu.au
434
Sch
edu
ling
© 2
020
Uw
e R
. Zim
mer
, The
Aus
tral
ian
Nat
iona
l Uni
vers
ity
page
434
of 7
58 (c
hapt
er 6
: “Sc
hedu
ling”
up
to p
age
459)
Defi
nit
ion
of t
erm
s
Tim
e sc
ales
of s
ched
ulin
g
©20
20U
we
RZ
imm
erTh
eA
ustr
alia
nN
atio
nalU
nive
rsity
page
434
ofy
758
(cha
pter
6:“S
ched
ulin
g”up
topa
ge45
9)8CPU
yd
aer
rea
dy,
su
spe
nd
ed
blo
ck
ed
, su
spe
nd
ed
blo
ck
ed
pre
-em
pti
on
or
cyc
le d
on
e
blo
ck
or
syn
ch
ron
ize
exe
cu
tin
gd
isp
atc
h
susp
en
d (
swap
-ou
t)
swap
-in
swap
-out
un
blo
ck
susp
en
d (
swap
-ou
t)
Short-term
Med
ium-term
431
Sch
edu
ling
© 2
020
Uw
e R
. Zim
mer
, The
Aus
tral
ian
Nat
iona
l Uni
vers
ity
page
431
of 7
58 (c
hapt
er 6
: “Sc
hedu
ling”
up
to p
age
459)
Mot
ivat
ion
and
defi
niti
on o
f ter
ms
Purp
ose
of s
ched
ulin
g
Two
sce
nar
ios
for
sch
edu
ling
algo
rith
ms:
1. O
rder
ing
reso
urc
e as
sign
men
ts (C
PU ti
me,
net
wo
rk a
cces
s, …
). l
ive,
on
-lin
e ap
plic
atio
n o
f sch
edu
ling
algo
rith
ms.
2. P
red
icti
ng
syst
em b
ehav
iou
rs u
nd
er a
nti
cip
ated
load
s. s
imu
late
d, o
ff-l
ine
app
licat
ion
of s
ched
ulin
g al
gori
thm
s.
Pred
icti
on
s ar
e u
sed
:
• at
co
mp
ile t
ime:
to c
on
fi rm
the
feas
ibili
ty o
f th
e sy
stem
, or
to p
red
ict r
eso
urc
e n
eed
s, …
• at
ru
n t
ime:
to p
erm
it a
dm
itta
nce
of n
ew r
equ
ests
or
for
load
-bal
anci
ng,
…
428
6Sc
hedu
ling
Uw
e R
. Zim
mer
- T
he A
ustr
alia
n N
atio
nal U
nive
rsity
Syst
ems,
Net
wo
rks
& C
on
curr
ency
202
0
435
Sch
edu
ling
© 2
020
Uw
e R
. Zim
mer
, The
Aus
tral
ian
Nat
iona
l Uni
vers
ity
page
435
of 7
58 (c
hapt
er 6
: “Sc
hedu
ling”
up
to p
age
459)
Defi
nit
ion
of t
erm
s
Tim
e sc
ales
of s
ched
ulin
g
©20
20U
we
RZ
imm
erTh
eA
ustr
alia
nN
atio
nalU
nive
rsity
page
435
ofy
758
(cha
pter
6:“S
ched
ulin
g”up
topa
ge45
9)8CPU
cre
ati
on
yd
aer
hct
ab
rea
dy,
su
spe
nd
ed
blo
ck
ed
, su
spe
nd
ed
blo
ck
ed
pre
-em
pti
on
or
cyc
le d
on
e
term
inate
.
blo
ck
or
syn
ch
ron
ize
exe
cu
tin
gad
mit
dis
patc
h
susp
en
d (
swap
-ou
t)
swap
-in
swap
-out
un
blo
ck
susp
en
d (
swap
-ou
t)
Long
-term
Short-term
Med
ium-term
432
Sch
edu
ling
© 2
020
Uw
e R
. Zim
mer
, The
Aus
tral
ian
Nat
iona
l Uni
vers
ity
page
432
of 7
58 (c
hapt
er 6
: “Sc
hedu
ling”
up
to p
age
459)
Mot
ivat
ion
and
defi
niti
on o
f ter
ms
Cri
teri
a
Perf
orm
ance
cri
teri
a:Pr
edic
tabi
lity
crit
eria
:
Pro
cess
/ u
ser
per
spec
tive
:
min
imiz
e th
e …
min
imiz
e d
evia
tio
n fr
om
giv
en …
Wai
ting
tim
em
inim
a / m
axim
a / a
vera
ge /
vari
ance
valu
e / m
inim
a / m
axim
a
Res
pons
e ti
me
min
ima
/ max
ima
/ ave
rage
/ va
rian
ceva
lue
/ min
ima
/ max
ima
/ dea
dlin
es
Turn
arou
nd t
ime
min
ima
/ max
ima
/ ave
rage
/ va
rian
ceva
lue
/ min
ima
/ max
ima
/ dea
dlin
es
Syst
em p
ersp
ecti
ve: m
axim
ize
the
…
Thro
ughp
utm
inim
a / m
axim
a / a
vera
ge
Uti
lizat
ion
CPU
bu
sy ti
me
429
Sch
edu
ling
© 2
020
Uw
e R
. Zim
mer
, The
Aus
tral
ian
Nat
iona
l Uni
vers
ity
page
429
of 7
58 (c
hapt
er 6
: “Sc
hedu
ling”
up
to p
age
459)
Ref
eren
ces
for
this
cha
pter
[ Ben
2006
] B
en-A
ri, M
Pr
inci
ple
s o
f Co
ncu
rren
t an
d D
is-
trib
ute
d P
rogr
amm
ing
seco
nd
ed
itio
n, P
ren
tice
-Hal
l 200
6
[Ad
aRM
2012
]A
da
Refe
ren
ce M
anu
al -
Lan
-gu
age
and
Sta
nd
ard
Lib
rari
es;
ISO
/IEC
865
2:20
1x (E
)
[ Sta
lling
s200
1 ] St
allin
gs, W
illia
m
Op
erat
ing
Syst
ems
Pren
tice
Hal
l, 20
01
436
Sch
edu
ling
© 2
020
Uw
e R
. Zim
mer
, The
Aus
tral
ian
Nat
iona
l Uni
vers
ity
page
436
of 7
58 (c
hapt
er 6
: “Sc
hedu
ling”
up
to p
age
459)
Perf
orm
ance
sch
edul
ing
Req
uest
ed r
eso
urce
tim
es
tim
e0
510
1520
2530
3540
45(T
i, C
i)
(4, 1
)
(12,
3)
(16,
8)
Task
s h
ave
an a
vera
ge t
ime
betw
een
inst
anti
atio
ns o
f T
i
and
a c
on
stan
t com
puta
tion
tim
e o
f C
i
433
Sch
edu
ling
© 2
020
Uw
e R
. Zim
mer
, The
Aus
tral
ian
Nat
iona
l Uni
vers
ity
page
433
of 7
58 (c
hapt
er 6
: “Sc
hedu
ling”
up
to p
age
459)
Defi
nit
ion
of t
erm
s
Tim
e sc
ales
of s
ched
ulin
g
©20
20U
we
RZ
imm
erTh
eA
ustr
alia
nN
atio
nalU
nive
rsity
page
433
ofy
758
(cha
pter
6:“S
ched
ulin
g”up
topa
ge45
9)8CPU
yd
aer
blo
ck
ed
pre
-em
pti
on
or
cyc
le d
on
e
blo
ck
or
syn
ch
ron
ize
exe
cu
tin
gd
isp
atc
h
Short-term
430
Sch
edu
ling
© 2
020
Uw
e R
. Zim
mer
, The
Aus
tral
ian
Nat
iona
l Uni
vers
ity
page
430
of 7
58 (c
hapt
er 6
: “Sc
hedu
ling”
up
to p
age
459)
Mot
ivat
ion
and
defi
niti
on o
f ter
ms
Purp
ose
of s
ched
ulin
g
443
Sch
edu
ling
© 2
020
Uw
e R
. Zim
mer
, The
Aus
tral
ian
Nat
iona
l Uni
vers
ity
page
443
of 7
58 (c
hapt
er 6
: “Sc
hedu
ling”
up
to p
age
459)
Perf
orm
ance
sch
edul
ing
Sho
rtes
t jo
b fi
rst
tim
e0
510
1520
2530
3540
45(T
i, C
i)
(4, 1
)
(12,
3)
(16,
8)
Wai
ting
tim
e: 0
..11,
ave
rage
: 3.7
– T
urna
roun
d ti
me:
1..1
4, a
vera
ge: 6
.3
Op
tim
ized
for
goo
d a
vera
ge p
erfo
rman
ce w
ith
min
imal
task
-sw
itch
es.
Pre
fers
sh
ort
task
s b
ut a
ll ta
sks
will
be
han
dle
d.
Goo
d ch
oice
if c
ompu
tati
on t
imes
are
kno
wn
and
task
sw
itch
es a
re e
xpen
sive
!
440
Sch
edu
ling
© 2
020
Uw
e R
. Zim
mer
, The
Aus
tral
ian
Nat
iona
l Uni
vers
ity
page
440
of 7
58 (c
hapt
er 6
: “Sc
hedu
ling”
up
to p
age
459)
Perf
orm
ance
sch
edul
ing
Feed
bac
k w
ith
2i p
re-e
mp
tio
n in
terv
als
• Im
ple
men
t mu
ltip
le
hie
rarc
hic
al r
ead
y-q
ueu
es.
• Fe
tch
pro
cess
es fr
om
the
hig
hes
t fi ll
ed r
ead
y q
ueu
e.
• D
isp
atch
mo
re C
PU ti
me
for
low
er p
rio
riti
es (
2i un
its)
.
Pro
cess
es o
n lo
wer
ran
ks
may
su
ffer
sta
rvat
ion.
New
an
d s
ho
rt ta
sks
will
be
pre
ferr
ed. .
CPU
pri
ori
ty 0
pri
ori
ty 1
exe
cu
tin
gad
mit
dis
patc
h 2
0
pri
ori
ty i
dis
patc
h 2
1
dis
patc
h 2
i
437
Sch
edu
ling
© 2
020
Uw
e R
. Zim
mer
, The
Aus
tral
ian
Nat
iona
l Uni
vers
ity
page
437
of 7
58 (c
hapt
er 6
: “Sc
hedu
ling”
up
to p
age
459)
Perf
orm
ance
sch
edul
ing
Firs
t co
me,
fi rs
t se
rved
(FC
FS)
tim
e0
510
1520
2530
3540
45(T
i, C
i)
(4, 1
)
(12,
3)
(16,
8)
Wai
ting
tim
e: 0
..11,
ave
rage
: 5.9
– T
urna
roun
d ti
me:
3..1
2, a
vera
ge: 8
.4
As
task
s ap
ply
co
ncu
rren
tly
for
reso
urc
es, t
he
actu
al s
equ
ence
of a
rriv
al is
no
n-d
eter
min
isti
c. h
ence
eve
n a
det
erm
inis
tic
sch
edu
ling
sch
ema
like
FCFS
can
lead
to d
iffe
ren
t ou
tco
mes
.
444
Sch
edu
ling
© 2
020
Uw
e R
. Zim
mer
, The
Aus
tral
ian
Nat
iona
l Uni
vers
ity
page
444
of 7
58 (c
hapt
er 6
: “Sc
hedu
ling”
up
to p
age
459)
Perf
orm
ance
sch
edul
ing
Sho
rtes
t jo
b fi
rst
tim
e0
510
1520
2530
3540
45(T
i, C
i)
(4, 1
)
(12,
3)
(16,
8)
Wai
ting
tim
e: 0
..10,
ave
rage
: 3.4
– T
urna
roun
d ti
me:
1..1
4, a
vera
ge: 6
.0
Can
be
sen
siti
ve to
no
n-d
eter
min
isti
c ar
riva
l seq
uen
ces.
441
Sch
edu
ling
© 2
020
Uw
e R
. Zim
mer
, The
Aus
tral
ian
Nat
iona
l Uni
vers
ity
page
441
of 7
58 (c
hapt
er 6
: “Sc
hedu
ling”
up
to p
age
459)
Perf
orm
ance
sch
edul
ing
Feed
bac
k w
ith
2i p
re-e
mp
tio
n in
terv
als
- se
que
ntia
l tim
e0
510
1520
2530
3540
45(T
i, C
i)
(4, 1
)
(12,
3)
(16,
8)
Wai
ting
tim
e: 0
..5, a
vera
ge: 1
.5 –
Tur
naro
und
tim
e: 1
..21,
ave
rage
: 5.7
Op
tim
ized
for
swif
t in
itia
l res
po
nse
s.
Pre
fers
sh
ort
task
s an
d lo
ng
task
s ca
n s
uff
er s
tarv
atio
n.
Ver
y sh
ort
init
ial r
espo
nse
tim
es! a
nd
go
od
ave
rage
turn
aro
un
d ti
mes
.
438
Sch
edu
ling
© 2
020
Uw
e R
. Zim
mer
, The
Aus
tral
ian
Nat
iona
l Uni
vers
ity
page
438
of 7
58 (c
hapt
er 6
: “Sc
hedu
ling”
up
to p
age
459)
Perf
orm
ance
sch
edul
ing
Firs
t co
me,
fi rs
t se
rved
(FC
FS)
tim
e0
510
1520
2530
3540
45(T
i, C
i)
(4, 1
)
(12,
3)
(16,
8)
Wai
ting
tim
e: 0
..11,
ave
rage
: 5.4
– T
urna
roun
d ti
me:
3..1
2, a
vera
ge: 8
.0
In
this
exa
mp
le:
the
aver
age
wai
tin
g ti
mes
var
y b
etw
een
5.4
an
d 5
.9th
e av
erag
e tu
rnar
ou
nd
tim
es v
ary
bet
wee
n 8
.0 a
nd
8.4
Sho
rtes
t po
ssib
le m
axim
al t
urna
roun
d ti
me!
445
Sch
edu
ling
© 2
020
Uw
e R
. Zim
mer
, The
Aus
tral
ian
Nat
iona
l Uni
vers
ity
page
445
of 7
58 (c
hapt
er 6
: “Sc
hedu
ling”
up
to p
age
459)
Perf
orm
ance
sch
edul
ing
Hig
hest
Res
po
nse
Rat
ion
CW
Ci
ii
+ F
irst
(HR
RF)
tim
e0
510
1520
2530
3540
45(T
i, C
i)
(4, 1
)
(12,
3)
(16,
8)
Wai
ting
tim
e: 0
..9, a
vera
ge: 4
.1 –
Tur
naro
und
tim
e: 2
..13,
ave
rage
: 6.6
Ble
nd
bet
wee
n S
ho
rtes
t-Jo
b-F
irst
an
d F
irst
-Co
me-
Firs
t-Se
rved
.
Pre
fers
sh
ort
task
s b
ut l
on
g ta
sks
gain
pre
fere
nce
ove
r ti
me.
Mor
e ta
sk s
wit
ches
and
wor
se a
vera
ges
than
SJF
but
bet
ter
uppe
r bo
unds
!
442
Sch
edu
ling
© 2
020
Uw
e R
. Zim
mer
, The
Aus
tral
ian
Nat
iona
l Uni
vers
ity
page
442
of 7
58 (c
hapt
er 6
: “Sc
hedu
ling”
up
to p
age
459)
Perf
orm
ance
sch
edul
ing
Feed
bac
k w
ith
2i p
re-e
mp
tio
n in
terv
als
- ov
erla
pp
ing tim
e0
510
1520
2530
3540
45(T
i, C
i)
(4, 1
)
(12,
3)
(16,
8)
Wai
ting
tim
e: 0
..3, a
vera
ge: 0
.9 –
Tur
naro
und
tim
e: 1
..45,
ave
rage
: 7.7
Op
tim
ized
for
swif
t in
itia
l res
po
nse
s.
Pre
fers
sh
ort
task
s an
d lo
ng
task
s ca
n s
uff
er s
tarv
atio
n.
Lon
g ta
sks
are
dela
yed
unti
l all
queu
es r
un e
mpt
y!
439
Sch
edu
ling
© 2
020
Uw
e R
. Zim
mer
, The
Aus
tral
ian
Nat
iona
l Uni
vers
ity
page
439
of 7
58 (c
hapt
er 6
: “Sc
hedu
ling”
up
to p
age
459)
Perf
orm
ance
sch
edul
ing
Roun
d R
ob
in (R
R)
tim
e0
510
1520
2530
3540
45(T
i, C
i)
(4, 1
)
(12,
3)
(16,
8)
Wai
ting
tim
e: 0
..5, a
vera
ge: 1
.2 –
Tur
naro
und
tim
e: 1
..20,
ave
rage
: 5.8
Op
tim
ized
for
swif
t in
itia
l res
po
nse
s.
“St
retc
hes
ou
t” lo
ng
task
s.
Bou
nd m
axim
al w
aiti
ng t
ime!
(d
epen
ded
on
ly o
n th
e n
um
ber
of t
asks
)
452
Scheduling
© 2020 Uwe R. Zimmer, The Australian National University page 452 of 758 (chapter 6: “Scheduling” up to page 459)
Performance scheduling
Comparison overviewSelection
Pre-emption
Waiting TurnaroundPreferred
jobsStarvation possible?
Methods without any knowledge about the processes
FCFS ( )max Wi no longlong average & short maximum
equal no
RR equal share yes boundgood average & large maximum
short no
FBpriority queues
yes very shortshort average & long maximum
short no
Methods employing computation time Ci and elapsed time Ei
SJF ( )min Ci no medium medium short yes
HRRF ( )max CW C
ii i+ no
controllable compromise
controllable compromise
controllable no
SRTF ( )min C Ei i- yes very short wide variance short yes
449
Scheduling
© 2020 Uwe R. Zimmer, The Australian National University page 449 of 758 (chapter 6: “Scheduling” up to page 459)
Performance scheduling
Comparison by shortest average waiting
time0 5 10 15 20 25 30 35 40 45
FCFS
FCFS
RR
FB-seq.
FB-ovlp
SJF
SJF
HRRF
SRTF
Providing short average waiting times Very swift response in most cases
Waiting times
Turnaround times
Averages
446
Scheduling
© 2020 Uwe R. Zimmer, The Australian National University page 446 of 758 (chapter 6: “Scheduling” up to page 459)
Performance scheduling
Shortest Remaining Time First (SRTF)
time0 5 10 15 20 25 30 35 40 45(Ti, Ci)
(4, 1)
(12, 3)
(16, 8)
Waiting time: 0..6, average: 0.7 – Turnaround time: 1..21, average: 4.4
Optimized for good averages.
Prefers short tasks and long tasks can suffer starvation..
Better averages than Feedback scheduling but with longer absolute waiting times!
453
Scheduling
© 2020 Uwe R. Zimmer, The Australian National University page 453 of 758 (chapter 6: “Scheduling” up to page 459)
Predictable scheduling
Towards predictable scheduling …
Task requirements (Quality of service):
Guarantee data fl ow levels
Guarantee reaction times
Guarantee deadlines
Guarantee delivery times
Provide bounds for the variations in results
Examples:
• Streaming media broadcasts, playing HD videos, live mixing audio/video, …
• Reacting to users, Reacting to alarm situations, …
• Delivering a signal to the physical world at the required time, …
450
Scheduling
© 2020 Uwe R. Zimmer, The Australian National University page 450 of 758 (chapter 6: “Scheduling” up to page 459)
Performance scheduling
Comparison by shortest maximal turnaround
time0 5 10 15 20 25 30 35 40 45
FCFS
FCFS
RR
FB-seq.FB-
ovlp
SJF
SJF
HRRF
SRTF
Providing upper bounds to turnaround times No tasks are left behind
Waiting times
Turnaround times
Averages
447
Scheduling
© 2020 Uwe R. Zimmer, The Australian National University page 447 of 758 (chapter 6: “Scheduling” up to page 459)
Performance scheduling
Comparison (in order of appearance)
time0 5 10 15 20 25 30 35 40 45
FCFS
FCFS
RR
FB-seq.FB-
ovlp
SJF
SJF
HRRF
SRTF
Waiting times
Turnaround times
Averages
454
Scheduling
© 2020 Uwe R. Zimmer, The Australian National University page 454 of 758 (chapter 6: “Scheduling” up to page 459)
Predictable scheduling
Temporal scopes
Common attributes:
• Minimal & maximal delay after creation
• Maximal elapsed time
• Maximal execution time
• Absolute deadline Task i
t1 0352025 10
deadline
min. delaymax. delay
created
max. elapse time
max. exec. time
451
Scheduling
© 2020 Uwe R. Zimmer, The Australian National University page 451 of 758 (chapter 6: “Scheduling” up to page 459)
Performance scheduling
Comparison by shortest average turnaround
time0 5 10 15 20 25 30 35 40 45
FCFS
FCFS
RR
FB-seq.
FB-ovlp
SJF
SJF
HRRF
SRTF
Providing good average performance High throughput systems
Waiting times
Turnaround times
Averages
448
Scheduling
© 2020 Uwe R. Zimmer, The Australian National University page 448 of 758 (chapter 6: “Scheduling” up to page 459)
Performance scheduling
Comparison by shortest maximal waiting
time0 5 10 15 20 25 30 35 40 45
FCFS
FCFS
RR
FB-seq.FB-
ovlp
SJF
SJF
HRRF
SRTF
Providing upper bounds to waiting times Swift response systems
Waiting times
Turnaround times
Averages
458
Scheduling
© 2020 Uwe R. Zimmer, The Australian National University page 458 of 758 (chapter 6: “Scheduling” up to page 459)
Predictable scheduling
Common temporal scope attributes
Temporal scopes can be:
Periodic controllers, routers, schedulers, streaming processes, …
Aperiodic periodic ‘on average’ tasks, i.e. regular but not rigidly timed, …
Sporadic / Transient user requests, alarms, I/O interaction, …
Deadlines can be:
“Hard” single failure leads to severe malfunction and/or disaster
“Firm” results are meaningless after the deadline
only multiple or permanent failures lead to malfunction
“Soft” results are still useful after the deadline
© 2020 U© 2020 U© 2020 U© 2020 U© 2020 U© 2020 U2020 U2020 U2020 U2020 U020 U020 U020020 U020 U20 U20 U0 U0 U0 UUUwewewewwwwwwwwewwwwee R. Zim
““
Sem
anti
cs d
efi n
ed
by
app
licat
ion
455
Scheduling
© 2020 Uwe R. Zimmer, The Australian National University page 455 of 758 (chapter 6: “Scheduling” up to page 459)
Predictable scheduling
Temporal scopes
Common attributes:
• Minimal & maximal delay after creation
• Maximal elapsed time
• Maximal execution time
• Absolute deadline Task i
t1 0352025 10
deadline
min. delaymax. delay
activatedcreated
max. elapse time
max. exec. time
459
Scheduling
© 2020 Uwe R. Zimmer, The Australian National University page 459 of 758 (chapter 6: “Scheduling” up to page 459)
Summary
Scheduling
• Basic performance scheduling
• Motivation & Terms
• Levels of knowledge / assumptions about the task set
• Evaluation of performance and selection of appropriate methods
• Towards predictable scheduling
• Motivation & Terms
• Categories & Examples
456
Scheduling
© 2020 Uwe R. Zimmer, The Australian National University page 456 of 758 (chapter 6: “Scheduling” up to page 459)
Predictable scheduling
Temporal scopes
Common attributes:
• Minimal & maximal delay after creation
• Maximal elapsed time
• Maximal execution time
• Absolute deadline Task i
t1 0352025 10
deadline
min. delaymax. delay
activated
suspended
re-activated
terminated
created
elapse time
max. elapse time
max. exec. time
457
Scheduling
© 2020 Uwe R. Zimmer, The Australian National University page 457 of 758 (chapter 6: “Scheduling” up to page 459)
Predictable scheduling
Temporal scopes
Common attributes:
• Minimal & maximal delay after creation
• Maximal elapsed time
• Maximal execution time
• Absolute deadline Task i
t1 0352025 10
deadline
execution time
min. delaymax. delay
activated
suspended
re-activated
terminated
created
elapse time
max. elapse time
max. exec. time