Upload
leonard-saja
View
239
Download
0
Embed Size (px)
Citation preview
8/10/2019 Real Time System.doc
1/32
Priority-driven Scheduling of
Periodic Tasks (1)
Sistem Waktu Nyata
Kuliah 5
8/10/2019 Real Time System.doc
2/32
Lecture Outline
Assumptions
Fixed-priority algorithmso Rate monotonic
o Deadline monotonic
Dynamic-priority algorithmso Earliest deadline rst
o !east slack time
Relati"e merits o# xed- and dynamic-priorityscheduling
Schedula$le utili%ation and proo# o# schedula$ility
&aterial in lectures 5 ' ( corresponds to chapter ( o#!iu)s $ook
8/10/2019 Real Time System.doc
3/32
8/10/2019 Real Time System.doc
4/32
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
o1here are no aperiodic or sporadic tasks
o Scheduling decisions made immediately upon 0o$ releaseand completion
Algorithms are e"ent dri"en2 not clock dri"en
Ne"er intentionally lea"e a resource idle
8/10/2019 Real Time System.doc
5/32
o ontext s.itch o"erhead negligi$ly small/ unlimited priority
le"els
8/10/2019 Real Time System.doc
6/32
ynamic versus Static Systems Recall #rom lecture 3+
o 4# 0o$s are scheduled on multiple processors2 and a 0o$ can$e dispatched toany o# the processors2 the system isdynamic
o 4# 0o$s are partitioned into su$systems2 each su$system
$ound statically toa processor2 .e ha"e a static systemo Dicult to determine the $est- and .orst-case per#ormance
o# dynamicsystems2 so most hard real-time systems $uiltare static
4n static systems2 the scheduler #or each processorschedules 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 eachsu$system o# a static multiprocessor system
8/10/2019 Real Time System.doc
7/32
o1hey are not applica$le to dynamic multiprocessor systems
8/10/2019 Real Time System.doc
8/32
!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+ insteadassigns prioritiesto 0o$s .hen released2 places them on arun 7ueue in priority order
o When pre-emption is allo.ed2 a scheduling decision is
made .hene"er a0o$ is released or completedo At each scheduling decision time2 the scheduler updates
the run 7ueues andexecutes the 0o$ at the head o# the7ueue
,o$s in a task may $e assigned the same priority 8tasklevel fxedpriority9 or di:erent priorities 8task leveldynamic-priority9
1he priority o# each 0o$ is usually xed 8job levelfxed-priority9/ $ut some systems can "ary the priorityo# a 0o$ a#ter it has started 8job level dynamic-priority9
o,o$ le"el dynamic-priority usually "ery inecient
8/10/2019 Real Time System.doc
9/32
#ate $onotonic Scheduling
;est kno.n xed-priority algorithm is rate monotonicscheduling
Assigns priorities to tasks $ased on their periodso1he shorter the period2 the higher the priority
o1he rate 8o# 0o$ releases9 is the in"erse o# the period2 so
0o$s .ith higherrate ha"e higher priority 8?2 =9 rate > @
o1 > 852 9 rate > =65
o13 > 8B2 59 rate > =6B
o Relati"e priorities+ 1= C 1 C 13
8/10/2019 Real Time System.doc
10/32
%"ample& #ate $onotonic Scheduling
8/10/2019 Real Time System.doc
11/32
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 T19 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 T218 - -
19 - -
8/10/2019 Real Time System.doc
12/32
eadline $onotonic Scheduling
1he deadline monotonic algorithm assigns taskpriority according to relati"e deadlines the shorterthe relati"e deadline2 the higher the priority
When relati"e deadline o# e"ery task matches itsperiod2 then rate monotonic and deadline monotonicgi"e identical results
When the relati"e deadlines are ar$itrary+
8/10/2019 Real Time System.doc
13/32
o Deadline monotonic can sometimes produce a #easi$le
schedule in cases.here rate monotonic cannoto
;ut2 rate monotonic al.ays #ails .hen deadline monotonic#ails
Deadline monotonic pre#erred to rate monotonico 4# deadline period
8/10/2019 Real Time System.doc
14/32
ynamic-Priority Algorithms Discussed se"eral dynamic-priority algorithms in
lecture 3+o Earliest deadline rst 8EDF9
1he 0o$ 7ueue is ordered $y earliest deadlineo !east slack time rst 8!S19
1he 0o$ 7ueue is ordered $y least slack time
1.o "ariations+ Strict !S1 scheduling decisions are made also .hene"er a7ueued 0o$)s slacktime $ecomes smaller than the executing0o$)s slack time huge o"erheads2 notused
Non-strict !S1 scheduling decisions made only .hen 0o$srelease or complete
o First in2 rst out 8F4F9
,o$ 7ueue is rst-in-rst-out $y release timeo !ast in2 rst out 8!4F9
,o$ 7ueue is last-in-rst-out $y release time
Focus on EDF as commonly used example
8/10/2019 Real Time System.doc
15/32
%"ample& %arliest eadline !irst
8/10/2019 Real Time System.doc
16/32
Time Ready To Run Running
0 T1,T2 T1
0,5 T1,T2 T1
1 T2 T21,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 T26 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
8/10/2019 Real Time System.doc
17/32
#elative $erits
Fixed- and dynamic-priority scheduling algorithmsha"e di:erent properties/ neither appropriate #or allscenarios
Algorithms that do not take into account the
urgencies o# 0o$s in priority assignment usuallyper#orm poorly
o Eg F4F2 !4F
8/10/2019 Real Time System.doc
18/32
1he EDF algorithm gi"es higher priority to 0o$s thatha"e missed their deadlines than to 0o$s .hose
deadline is still in the #utureo Not necessarily suited to systems .here occasional
o"erload una"oida$le
Dynamic algorithms like EDF can produce #easi$leschedules in cases .here R& and D& cannot
o ;ut xed priority algorithms o#ten more predicta$le2 lo.ero"erhead
8/10/2019 Real Time System.doc
19/32
%"ample& 'omparing ierent Algorithms
ompare per#ormance o# R&2 EDF2 !S1 and F4Fscheduling
Assume a single processor system .ith tasks+o1= > 82 =9
o1 > 852 59 H > =B
1he total utili%ation is =B
no slack timeo Expect some o# these algorithms to lead to missed
deadlinesGo1his is one o# the cases .here EDF .orks $etter than
R&6D&
8/10/2019 Real Time System.doc
20/32
%"ample& #$ %! LST and !*!O
Demonstrate $y exhausti"e simulation that !S1 andEDF meet deadlines2 $ut F4F and R& don)t
8/10/2019 Real Time System.doc
21/32
Schedula+ility Tests
Simulating schedules is $oth tedious and error-proneH can .e demonstrate correctness .ithout.orking through the scheduleI
Jes2 in some cases 1his is a schedulability testo A test to demonstrate that all deadlines are met2 .hen
scheduled using aparticular algorithmo An ecient schedula$ility test can $e used as an on-line
acceptance test/clearly exhausti"e simulation is tooexpensi"e
8/10/2019 Real Time System.doc
22/32
Schedula+le ,tiliation
Recall+ a periodic task Ti is dened $y the ?-tuple 8 i2pi2 ei2 Di9 .ith utili%ation ui > ei 6pi
1otal utili%ation o# the system ==n
i iuU
1 .here B U =
A scheduling algorithm can #easi$ly schedule anysystem o# periodic tasks on a processor i# U is e7ual toor 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 aschedula$ility test2 .here a system can $e "alidated$y sho.ing that U UAL
8/10/2019 Real Time System.doc
23/32
Schedula+le ,tiliation& %!
1heorem+ a system o# independent preempta$leperiodic tasks .ith Di >pi can $e #easi$ly scheduledon one processor using EDF i# and only i# U =
o U!D" > = #or independent2 preempta$le periodic tasks .ithDi >pi
LExpected since EDF pro"ed optimalin lecture 3 see the $ook #or proo#M
o orollary+ result also holds i# deadline longer than period+U!D" > = #orindependent preempta$le periodic tasks .ith Dipi
Notes+
o Result is independent o# io Result can also $e sho.n to apply to strict !S1
8/10/2019 Real Time System.doc
24/32
8/10/2019 Real Time System.doc
25/32
might still $e #easi$le i# C =8.ould ha"e to run theexhausti"e simulation to pro"e9
8/10/2019 Real Time System.doc
26/32
Schedula+le ,tiliation& %!
Po. can you use this in practiceIo Assume using EDF to schedule multiple periodic tasks2
kno.n executiontime #or all 0o$shoose 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= > ms2 sampling
rate is =BB P%8iep= > =B ms9
u= is B
the system is guaranteed to $e schedula$leo Want to add a $uilt-in sel# test task2 T2 taking 5Bms - .ill
the system still.orkI
8/10/2019 Real Time System.doc
27/32
Schedula+le ,tiliation of #$
1heorem+ a system o# n independent preempta$leperiodic tasks .ith Di >pi can $e #easi$ly scheduled
on one processor using R& i# and only i# U n
8=6n
=9
o U#$8n9 > n8=6n =9
o For large n ln
8ie n B(3=?T=B5(H9
o L*roo# in $ook -
complicatedGM
8/10/2019 Real Time System.doc
28/32
o U U#$8n9 is a sucient2 $ut not necessary2 condition ie
a #easi$le ratemonotonic schedule is guaranteed to exist i#U U#$8n92 $ut might still $epossi$le i# U C U#$8n9
8/10/2019 Real Time System.doc
29/32
Schedula+le ,tiliation 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+
8/10/2019 Real Time System.doc
30/32
Schedula+le ,tiliation of #$
8/10/2019 Real Time System.doc
31/32
8/10/2019 Real Time System.doc
32/32