Anda di halaman 1dari 32

Priority-driven Scheduling of

Periodic Tasks (1)


Sistem Waktu Nyata
Kuliah 5
Lecture Outline
Assumptions
Fixed-priority algorithms
o Rate monotonic
o Deadline monotonic
Dynamic-priority algorithms
o Earliest deadline rst
o !east slack time
Relati"e merits o# xed- and dynamic-priority
scheduling
Schedula$le utili%ation and proo# o# schedula$ility
&aterial in lectures 5 ' ( corresponds to chapter ( o#
!iu)s $ook
Assumptions
*riority-dri"en scheduling o# periodic tasks on a single
processor
Assume a restricted periodic task model+
o A xed num$er o# independent periodic tasks exist
,o$s comprising those tasks+
Are ready #or execution as soon as they are released
-an $e pre-empted at any time
Ne"er suspend themsel"es
Ne. tasks only admitted a#ter an acceptance test/ may $e
re0ected
1he period o# a task dened as minimum inter-release time o#
0o$s in task
o 1here are no aperiodic or sporadic tasks
o Scheduling decisions made immediately upon 0o$ release
and completion
Algorithms are e"ent dri"en2 not clock dri"en
Ne"er intentionally lea"e a resource idle
o -ontext s.itch o"erhead negligi$ly small/ unlimited priority
le"els
ynamic versus Static Systems
Recall #rom lecture 3+
o 4# 0o$s are scheduled on multiple processors2 and a 0o$ can
$e dispatched to any o# the processors2 the system is
dynamic
o 4# 0o$s are partitioned into su$systems2 each su$system
$ound statically to a processor2 .e ha"e a static system
o Di5cult to determine the $est- and .orst-case per#ormance
o# dynamic systems2 so most hard real-time systems $uilt
are static
4n static systems2 the scheduler #or each processor
schedules the 0o$s in its su$system independent o#
the schedulers #or the other processors
Results demonstrated #or priority-dri"en
uniprocessor systems are applica$le to each
su$system o# a static multiprocessor system
o 1hey are not applica$le to dynamic multiprocessor systems
!i"ed- and ynamic-Priority Algorithms
A priority-dri"en scheduler is an on-line scheduler
o 4t does not pre-compute a schedule o# tasks60o$s+ instead
assigns priorities to 0o$s .hen released2 places them on a
run 7ueue in priority order
o When pre-emption is allo.ed2 a scheduling decision is
made .hene"er a 0o$ is released or completed
o At each scheduling decision time2 the scheduler updates
the run 7ueues and executes the 0o$ at the head o# the
7ueue
,o$s in a task may $e assigned the same priority 8task
level fxedpriority9 or di:erent priorities 8task level
dynamic-priority9
1he priority o# each 0o$ is usually xed 8job level
fxed-priority9/ $ut some systems can "ary the priority
o# a 0o$ a#ter it has started 8job level dynamic-priority9
o ,o$ le"el dynamic-priority usually "ery ine5cient
#ate $onotonic Scheduling
;est kno.n xed-priority algorithm is rate monotonic
scheduling
Assigns priorities to tasks $ased on their periods
o 1he shorter the period2 the higher the priority
o 1he rate 8o# 0o$ releases9 is the in"erse o# the period2 so
0o$s .ith higher rate ha"e higher priority
<ery .idely studied and used
For example2 consider a system o# 3 tasks+
o 1= > 8?2 =9 rate > @
o 1A > 852 A9 rate > =65
o 13 > 8AB2 59 rate > =6AB
o Relati"e priorities+ 1= C 1A C 13
%"ample& #ate $onotonic Scheduling
Time Ready To Run Running
0 T1,T2,T3 T1
1 T2,T3 T2
2 T2,T3 T2
3 T3 T3
4 T1,T3 T1
5 T2,T3 T2
6 T2,T3 T2
7 T3 T3
8 T1,T3 T1
9 T3 T3
Time Ready To Run Running
10 T2,T3 T2
11 T2,T3 T2
12 T1,T3 T1
13 T3 T3
14 T3 T3
15 T2 T2
16 T1,T2 T1
17 T2 T2
18 - -
19 - -
eadline $onotonic Scheduling
1he deadline monotonic algorithm assigns task
priority according to relati"e deadlines D the shorter
the relati"e deadline2 the higher the priority
When relati"e deadline o# e"ery task matches its
period2 then rate monotonic and deadline monotonic
gi"e identical results
When the relati"e deadlines are ar$itrary+
o Deadline monotonic can sometimes produce a #easi$le
schedule in cases .here rate monotonic cannot
o ;ut2 rate monotonic al.ays #ails .hen deadline monotonic
#ails
Deadline monotonic pre#erred to rate monotonic
o 4# deadline period
ynamic-Priority Algorithms
Discussed se"eral dynamic-priority algorithms in
lecture 3+
o Earliest deadline rst 8EDF9
D 1he 0o$ 7ueue is ordered $y earliest deadline
o !east slack time rst 8!S19
D 1he 0o$ 7ueue is ordered $y least slack time
D 1.o "ariations+
Strict !S1 D scheduling decisions are made also .hene"er a
7ueued 0o$)s slack time $ecomes smaller than the executing
0o$)s slack time D huge o"erheads2 not used
Non-strict !S1 D scheduling decisions made only .hen 0o$s
release or complete
o First in2 rst out 8F4FE9
D ,o$ 7ueue is rst-in-rst-out $y release time
o !ast in2 rst out 8!4FE9
D ,o$ 7ueue is last-in-rst-out $y release time
Focus on EDF as commonly used example
%"ample& %arliest eadline !irst
Time Ready To Run Running
0 T1,T2 T1
0,5 T1,T2 T1
1 T2 T2
1,5 T2 T2
2 T1,T2 T1
2,5 T1,T2 T1
3 T2 T2
3,5 T2 T2
4 T1,T2 T2
4,5 T1,T2 T2
Time Ready To Run Running
5 T1,T2 T1
5,5 T2 T2
6 T1,T2 T1
6,5 T1,T2 T1
7 T2 T2
7,5 T2 T2
8 T1,T2 T1
8,5 T1,T2 T1
9 T2 T2
9,5 T2 T2
#elative $erits
Fixed- and dynamic-priority scheduling algorithms
ha"e di:erent properties/ neither appropriate #or all
scenarios
Algorithms that do not take into account the
urgencies o# 0o$s in priority assignment usually
per#orm poorly
o EFg F4FE2 !4FE
1he EDF algorithm gi"es higher priority to 0o$s that
ha"e missed their deadlines than to 0o$s .hose
deadline is still in the #uture
o Not necessarily suited to systems .here occasional
o"erload una"oida$le
Dynamic algorithms like EDF can produce #easi$le
schedules in cases .here R& and D& cannot
o ;ut xed priority algorithms o#ten more predicta$le2 lo.er
o"erhead
%"ample& 'omparing i(erent Algorithms

-ompare per#ormance o# R&2 EDF2 !S1 and F4FE
scheduling
Assume a single processor system .ith A tasks+
o 1= > 8A2 =9
o 1A > 852 AF59 H > =B
1he total utili%ation is =FB no slack time
o Expect some o# these algorithms to lead to missed
deadlinesG
o 1his is one o# the cases .here EDF .orks $etter than
R&6D&
%"ample& #$) %!) LST and !*!O
Demonstrate $y exhausti"e simulation that !S1 and
EDF meet deadlines2 $ut F4FE and R& don)t
Schedula+ility Tests
Simulating schedules is $oth tedious and error-
proneH can .e demonstrate correctness .ithout
.orking through the scheduleI
Jes2 in some casesF 1his is a schedulability test
o A test to demonstrate that all deadlines are met2 .hen
scheduled using a particular algorithm
o An e5cient schedula$ility test can $e used as an on-line
acceptance test/ clearly exhausti"e simulation is too
expensi"e
Schedula+le ,tili-ation
Recall+ a periodic task Ti is dened $y the ?-tuple 8 i 2
pi2 ei2 Di9 .ith utili%ation ui > ei 6 pi
1otal utili%ation o# the system

=
=
n
i
i
u U
1 .here B K U K =
A scheduling algorithm can #easi$ly schedule any
system o# periodic tasks on a processor i# U is e7ual to
or less than the maximum schedula$le utili%ation o#
the algorithm2 UAL
o 4# UAL > =2 the algorithm is optimal
Why is kno.ing o# UAL importantI 4t gi"es a
schedula$ility test2 .here a system can $e "alidated
$y sho.ing that U K UAL
Schedula+le ,tili-ation& %!
1heorem+ a system o# independent preempta$le
periodic tasks .ith Di > pi can $e #easi$ly scheduled
on one processor using EDF i# and only i# U K =
o U!D" > = #or independent2 preempta$le periodic tasks .ith
Di > pi
LExpected since EDF pro"ed optimal
in lecture 3 D see the $ook #or proo#M
o -orollary+ result also holds i# deadline longer than period+
U!D" > = #or independent preempta$le periodic tasks .ith Di
N pi
Notes+
o Result is independent o# i
o Result can also $e sho.n to apply to strict !S1
Schedula+le ,tili-ation& %!
What happens i# Di O pi #or some iI 1he test doesn)t
.orkH
o EFgF
Po.e"er2 there is an alternati"e test+
o 1he density o# the task2 Ti2 is i > ei 6 min8Di2 pi9
o 1he density o# the system is > = Q A Q H Q n
o 1heorem+ A system T o# independent2 preempta$le periodic
tasks can $e #easi$ly scheduled on one processor using
ED1 i# K =F
Note+
o 1his is a su5cient condition2 $ut not a necessary condition
D iFeF a systemis guaranteed to $e #easi$le i# K =2 $ut
might still $e #easi$le i# C = 8.ould ha"e to run the
exhausti"e simulation to pro"e9
Schedula+le ,tili-ation& %!
Po. can you use this in practiceI
o Assume using EDF to schedule multiple periodic tasks2
kno.n execution time #or all 0o$s
-hoose the periods #or the tasks such that the
schedula$ility test is met
Example+ a simple digital controller+
o -ontrol-la. computation task2 T=2 takes e= > R ms2 sampling
rate is =BB P%
8iFeF p= > =B ms9
u= is BFR
the system is guaranteed to $e schedula$le
o Want to add a $uilt-in sel# test task2 TA2 taking 5Bms - .ill
the system still .orkI
Schedula+le ,tili-ation of #$
1heorem+ a system o# n independent preempta$le
periodic tasks .ith Di > pi can $e #easi$ly scheduled
on one processor using R& i# and only i# U K n8A=6n D
=9
o U#$8n9 > n8A=6n D =9
o For large n ln A
8iFeF n BF(S3=?T=RB5(H9
o L*roo# in $ook -
complicatedGM
o U K U#$8n9 is a su5cient2 $ut not necessary2 condition D iFeF
a #easi$le rate monotonic schedule is guaranteed to exist i#
U K U#$8n92 $ut might still $e possi$le i# U C U#$8n9
Schedula+le ,tili-ation of #$
What happens i# the relati"e deadlines #or tasks are
not e7ual to their respecti"e periodsI
Assume the deadline is some multiple o# the period+
Dk > pk
4t can $e sho.n that+
Schedula+le ,tili-ation of #$
Summary
Key points+
Di:erent priority scheduling algorithms
o Earliest deadline rst2 least slack time2 rate monotonic2
deadline monotonic
o Each has di:erent properties2 suited #or di:erent scenarios
Scheduling tests2 concept o# maximum schedula$le
utili%ation
o Examples #or di:erent algorithms
Next lecture+ practical #actors2 more schedula$ility
testsH

Anda mungkin juga menyukai