• No results found

PROCESSOR IS OCCUPIED BY T i

N/A
N/A
Protected

Academic year: 2021

Share "PROCESSOR IS OCCUPIED BY T i"

Copied!
15
0
0

Loading.... (view fulltext now)

Full text

(1)

in a Hard-Real-Time Environment

C. L. Liu

ProjectMAC, Massachusetts Instituteof Technology

James W. Layland

JetPropulsion Laboratory, CaliforniaInstitute of Technology

Abstract

Theproblemofmultiprogramschedulingonasingleprocessorisstudiedfromtheviewpoint

ofthecharacteristicspeculiartotheprogramfunctionthatneedguaranteedservice. Itisshown

that an optimum xed priority scheduler possesses anupperbound to processor utilization

which may be as low as 70 percent for large task sets. It is also shownthat full processor

utilization can be achievedby dynamically assigning priorities onthe basis of their current

deadlines. Acombinationofthesetwoschedulingtechniquesisalsodiscussed.

1 Introduction

The use of computersfor control and monitoring of industrial processeshas expanded greatlyin

recent years, and will probably expand even more dramatically in the near future. Often, the

computer used in such an applicationis shared betweenacertain numberof time-criticalcontrol

and monitorfunctionsand anon-time-criticalbatch processingjob stream. Inotherapplications,

however, no non-time-critical jobs exist, and eÆcient use of the computer can only be achieved

by acareful schedulingof thetime-critical control and monitorfunctions themselves. This latter

groupmightbetermed\pureprocess control"and providesthebackgroundfor thecombinatoric

schedulinganalysespresentedinthispaper. Twoschedulingalgorithmsforthistypeofprogramming

are studied; bothare priority driven andpreemptive; meaning that the processing ofany task is

interruptedbyarequestforanyhigherprioritytask. The rstalgorithmstudiedusesa xedpriority

assignmentand canachieveprocessorutilization onthe orderof 70percentormore. Thesecond

schedulingalgorithm canachievefull processorutilization by means of adynamic assignment of

priorities. A combinationofthesetwoalgorithmsisalsodiscussed.

2 Background

A processcontrolcomputerperformsoneormorecontroland monitoringfunctions. Thepointing

of anantennatotrackaspacecraftinitsorbitisoneexampleof suchfunctions. Each functionto

beperformedhasassociatedwithitasetofoneormoretasks. Someofthesetasksareexecutedin

responsetoeventsin theequipmentcontrolled ormonitoredbythecomputer. Theremainderare

executedin responseto eventsinothertasks. Noneofthetasksmaybeexecutedbeforetheevent

whichrequestsitoccurs. Eachofthetasksmustbecompletedbeforesome xedtimehaselapsed

Copyright 1973,c Asso ciationforComputingMachinery,Inc. Generalp ermissiontorepublish,butnotforprofit,allorpartofthismaterial

isgranted,providedthatreferenceismadetothispublication,toitsdateifissue,andtothefactthatreprintingprivilegeweregrantedby

p ermissionoftheAsso ciationforComputingMachinery.

Thispap erpresentstheresultsofonephaseofresearchcarriedoutattheJetPropulsionLab oratory,CaliforniaInstituteofTechnology,under

ContractNo.NAS-7-100,sp onsoredbytheNationalAeronauticsandSpaceAdministration.

Author'spresentaddresses:C.L.Liu,DepartmentofComputerScience,UniversityofIllinoisatUrbana-Champaign,Urbana,IL61801;James

(2)

environmentas\hard-real-time"[1]in contrastto \soft-real-time"where astatistical distribution

ofresponsetimesisacceptable.

Much of the available literature on multiprogramming deals with the statistical analysis of

commercial time-sharing systems([2] containsan extensive bibliography). Another subset deals

with themoreinterestingaspectsof schedulingabatch-processingfacilityoramixed

batch-time-sharingfacility,usuallyinamultipleprocessorcon guration[3]-[8]. Afewpapersdirectlyattackthe

problems of\hard-real-time"programming. Manacher[1] derivesanalgorithm forthegeneration

of task schedules in ahard-real-time environment, but his results are restrictedto the somewhat

unrealistic situation of only one request time for all tasks, even though multiple deadlines are

considered. Lampson[9]discussesthesoftwareschedulingproblemingeneraltermsandpresentsa

setof Algolmultiprogrammingprocedureswhichcouldbesoftware-implementedordesignedinto

aspecialpurposescheduler. Fortheallocationofresourcesandfortheassignmentofprioritiesand

timeslots, heproposesaprogramwhichcomputesestimatedresponse timedistributionsbasedon

the timing information supplied forprograms needing guaranteed service. He doesnot, however,

describethealgorithmswhich suchaprogrammustuse.

ThetextbyMartin[10]depictstherangeofsystemswhichareconsideredtobe\real-time"and

discussesinanorderlyfashiontheproblemswhichareencounteredinprogrammingthem. Martin's

description of the tight engineering management control that must be maintainedoverreal-time

software development is emphatically echoed in a paper by Jarauch [11] on automatic checkout

systemsoftware. Thesediscussionsserveto emphasizetheneedforamoresystematicapproachto

softwaredesignthaniscurrentlyinuse.

3 The Environment

Toobtainanyanalyticalresultsaboutprogrambehaviorin ahard-real-timeenvironment,certain

assumptions must bemade aboutthat environment. Not all of these assumptions areabsolutely

necessary,andthee ects ofrelaxingthemwillbediscussedin alatersection.

(A1) Therequestsforalltasks forwhichharddeadlinesexist are periodic,with constantinterval

betweenrequests.

(A2) Deadlinesconsistofrun-abilityconstraintsonly{i.e. eachtaskmustbecompletedbeforethe

nextrequestsforitoccurs.

(A3) Thetasksareindependentinthatrequestsforacertaintaskdonotdependontheinitialization

orthecompletionofrequestsforothertasks.

(A4) Run-timeforeachtaskisconstantforthattaskanddoesnotvarywithtime. Run-timerefers

tothetimewhich istakenbyaprocessortoexecutethetaskwithoutinterruption.

(A5) Anynon-periodictasksinthesystemarespecial;theyareinitializationorfailure-recovery

rou-tines;theydisplaceperiodictaskswhiletheythemselvesarebeingrun,anddonotthemselves

havehard,criticaldeadlines.

Assumption (A1) contrasts with the opinion of Martin [12], but appearsto be valid forpure

process control. Assumption (A2) eliminatesqueuing problems for the individual tasks. For

as-sumption(A2)tohold,asmallbutpossiblysigni cantamountofbu eringhardwaremustexistfor

eachperipheralfunction. Anycontrolloopsclosedwithinthecomputermustbedesignedtoallow

at leastan extraunit sampledelay. Note that assumption(A3) doesnotexcludethesituation in

which theoccurrenceofatask 

j

can onlyfollowacertain( xed)number,sayN, ofoccurrences

of atask 

i

. Such asituation can be modeled bychoosing theperiods oftasks 

i and j sothat the period of  j

is N times theperiod of 

i

and theNthrequest for

i

willcoincide with the1st

request for

j

and so on. Therun-time in assumption (A4) canbe interpreted as the maximum

(3)

0000

0000

1111

1111

0000

0000

1111

1111

0000

0000

1111

1111

00000

00000

11111

11111

00

00

00

00

11

11

11

11

000000000

000000000

000000000

000000000

111111111

111111111

111111111

111111111

000000000000000

000000000000000

000000000000000

000000000000000

111111111111111

111111111111111

111111111111111

111111111111111

000000

000000

000000

000000

111111

111111

111111

111111

t

1

t + T

1 m

PROCESSOR IS OCCUPIED BY T

i

t

2

t + C

2 i

t + T

2 i

t + 2T

2 i

t + kT

2 i

t

t

t + (k+1)T

2 i

Figure1: Executionof i

betweenrequestsfor

m

thecostsofpreemptionscanbetakenintoaccount. Becauseoftheexistenceoflargemainmemories

out ofwhich programsare executedand the overlappingof transfersbetween mainand auxiliary

storage and program executionin modern computersystems, assumption (A4) should be agood

approximationevenifitisnotexact. These assumptionsallowthecompletecharacterization ofa

taskbytwonumbers: itsrequestperiodanditsrun-time. Unlessstatedotherwise,throughoutthis

paperweshall use

i , 

2 , , 

m

to denotem periodic tasks,with theirrequestperiodsbeingT

1 , T 2 , , T m

and theirrun-times beingC

1 ,C

2 , , C

m

, respectively. The request rate of atask is

de ned tobethereciprocalofitsrequestperiod.

Aschedulingalgorithm isasetof rulesthat determinethetasktobeexecutedat aparticular

moment. Theschedulingalgorithmstobestudied inthispaperarepreemptiveandprioritydriven

ones. Thismeansthatwheneverthereisarequestforataskthatisofhigherprioritythantheone

currentlybeingexecuted,therunningtaskisimmediatelyinterruptedandthenewlyrequestedtask

isstarted. Thusthespeci cationofsuchalgorithmsamountsto thespeci cationofthemethod of

assigning priorities to tasks. A schedulingalgorithm is said to be static ifpriorities areassigned

to tasks once and for all. A static scheduling algorithm is also called a xed priority scheduling

algorithm. A schedulingalgorithm is saidto bedynamic ifpriorities of tasks mightchange from

requesttorequest. Aschedulingalgorithmissaidtobeamixedschedulingalgorithmifthepriorities

ofsomeofthetasksare xedyettheprioritiesoftheremainingtasksvaryfromrequesttorequest.

4 A Fixed Priority Scheduling Algorithm

In this section wederivea rule for priority assignment that yields anoptimum static scheduling

algorithm. Animportantconceptindeterminingthis ruleisthatofthecritical instant foratask.

The deadline of a request for a task is de ned to be the time of the next request for the same

task. Forasetoftasksscheduledaccordingto someschedulingalgorithm,wesaythatanover ow

occurs attimet iftis thedeadline ofanunful lledrequest. Foragivenset oftasks,ascheduling

algorithm isfeasible ifthetasksarescheduledsothatnoover oweveroccurs. Wede neresponse

time of a request fora certain task to be thetime span between the request and the end of the

responsetothatrequest. Acritical instant forataskisde nedtobeaninstantatwhicharequest

forthattaskwillhavethelargestresponsetime. Acritical timezone forataskisthetimeinterval

betweenacriticalinstantandtheendoftheresponsetothecorrespondingrequestofthetask. We

havethefollowingtheorem.

Theorem1 A critical instant for any task occurs whenever the task is requested simultaneously

with requestsfor allhigherpriority tasks.

Proof. Let 1 ,  2 ,, m

denoteaset ofpriority-orderedtaskswith 

m

beingthetask withthe

lowest priority. Consideraparticular request for 

m

that occurs at t

1

. Suppose that betweent

(4)

0000

0000

1111

1111

0000

0000

1111

1111

0000

0000

1111

1111

0

0

1

1

T

1

1

2

3

4

5

t

0000

0000

1111

1111

0

1

t

5

1

T

2

CRITICAL TIME ZONE

0000

0000

1111

1111

0000

0000

1111

1111

0000

0000

1111

1111

0

0

1

1

0

0

1

1

0

0

1

1

T

1

1

2

3

4

5

t

0000

0000

1111

1111

0

1

0000

0000

1111

1111

0

1

t

5

1

T

2

CRITICAL TIME ZONE

0000

0000

1111

1111

0

0

1

1

0000000000000000000000

1111111111111111111111

0000

0000

1111

1111

0

1

0

1

T

2

5

t

t

T

1

2

CRITICAL TIME ZONE

(c)

(a)

(b)

Figure2: Schedulingfortwotasks

and t

1 +T

m

, the timeat whichthe subsequentrequest of

m

occurs,requests fortask 

i , i<m, occuratt 2 ,t 2 +T i ,t 2 +2T i ,,t 2 +kT i

asillustratedinFigure1. Clearly,thepreemptionof

m

by

i

willcauseacertainamountofdelayinthecompletionoftherequest for

m

thatoccurredat

t

1

,unless therequest for

m

is completed before t

2

. Moreover,from Figure1wesee immediately

thatadvancingtherequesttimet

2

willnotspeedupthecompletionof

m

. Thecompletiontimeof



m

iseitherunchangedordelayedbysuchadvancement. Consequently,thedelayinthecompletion

of m islargestwhent 2 coincideswitht 1 .

Repeatingtheargumentforall

i

,i=2,,m 1,weprovethetheorem. 2

Oneofthevaluesofthisresultisthatasimpledirectcalculationcandeterminewhetherornot

agivenpriorityassignmentwillyieldafeasibleschedulingalgorithm. Speci cally,iftherequestsfor

alltasksattheircriticalinstantsareful lledbeforetheirrespectivedeadlines,thenthescheduling

algorithmisfeasible. Asanexample,considerasetoftwotasks

1 and 2 withT 1 =2,T 2 =5,and C 1 =1,C 2 =1. Ifwelet 1

bethehigher priority task, thenfrom Figure 2(a)wesee that such

apriorityassignmentisfeasible. Moreover,thevalueof C

2

canbe increasedatmostto 2but not

further asillustratedin Figure 2(b). On theother hand, ifwe let

2

bethe higherprioritytask,

thenneitherofthevaluesofC

1 andC

2

canbeincreasedbeyond1asillustratedinFigure 2(c).

TheresultinTheorem 1also suggestsapriorityassignmentthat isoptimumin thesensethat

willbestatedinTheorem2. Letusmotivatethegeneralresultbyconsideringthecaseofscheduling

twotasks 1 and 2 . LetT 1 andT 2

betherequestperiodsofthetasks,withT

1 <T 2 . Ifwelet 1 be

thehigherprioritytask,then,accordingtoTheorem1,thefollowinginequalitymustbesatis ed: 12 bT 2 =T 1 cC 1 +C 2 T 2 : (1) Ifwelet 2

bethehigherprioritytask,then,thefollowinginequalitymustbesatis ed:

C 1 +C 2 T 1 : (2) Since bT 2 =T 1 cC 1 +bT 2 =T 1 cC 2 bT 2 =T 1 cT 1 T 2 ; 1

It should be pointed out that (1) isnecessary but not suÆcient to guarantee the feasibility of the priority

assignment.

2

(5)

1 2 1 2

is feasible with

2

at higherprioritythan 

1

, itit also feasiblewith 

1

at higherpriority than

2 .

Hence,moregenerally,itseemsthata\reasonable"ruleofpriorityassignmentistoassignpriorities

to tasksaccording to theirrequest rates, independent of their run-times. Speci cally, taskswith

higher requestrateswill havehigherpriorities. Such anassignmentofpriorities will beknownas

the rate-monotonic priority assignment. As it turns out, such apriority assignment is optimum

in the sense that noother xed priorityassignmentrulecanschedulea taskset which cannotbe

scheduledbytherate-monotonicpriorityassignment.

Theorem2 If afeasiblepriority assignment existsfor sometaskset,the rate-monotonicpriority

isfeasiblefor that taskset.

Proof. Let 1 ,  2 , ,  m

beaset ofm taskswith acertain feasiblepriorityassignment. Let

i

and 

j

betwotasks ofadjacentprioritiesin such anassignmentwith 

i

beingthehigherpriority

one. Suppose thatT

i >T

j

. Letusinterchangethepriorities of

i and

j

. Itis notdiÆculttosee

thattheresultantpriorityassignmentisstillfeasible. Sincetherate-monotonicpriorityassignment

canbeobtainedfromanypriorityorderingbyasequenceofpairwisepriorityreorderingsasabove,

weprovethetheorem. 2

5 Achievable Processor Utilization

At thispoint,thetoolsare available todetermine aleastupperbound to processorutilization in

xed priority systems. We de nethe(processor) utilization factor to be thefractionof processor

time spent in the executionof thetask set. Inother words, theutilization factor is equalto one

minus the fraction of idle processortime. Since C

i =T

i

is the fraction of processor time spent in

executingtask

i

,formtasks,theutilizationfactoris:

U = m X i=1 (C i =T i )

Although the processorutilization factor canbe improved byincreasing thevalues ofthe C

i 's or

by decreasingthe valuesoftheT

i

's, itis upperboundedby therequirementthat all taskssatisfy

theirdeadlines attheir criticalinstants. Itis clearlyuninterestingtoask howsmall theprocessor

utilization factor can be. Let us be precise about what we mean. Corresponding to a priority

assignment,aset oftasksis saidtofully utilize theprocessorifthepriorityassignmentis feasible

for theset and ifanincreasein the run-timeofanyof thetasks in theset will makethepriority

assignmentinfeasible. Foragiven xedpriorityschedulingalgorithm,theleastupper bound ofthe

utilization factor is theminimum of the utilization factors over allsets of tasksthat fully utilize

theprocessor. Foralltasksetswhose processorutilization factorisbelowthis bound,thereexists

a xedpriorityassignmentwhichisfeasible. Ontheotherhand,utilization abovethis bound can

onlybeachievediftheT

i

ofthetasksaresuitably related.

Sincetherate-monotonicpriorityassignmentisoptimum,theutilizationfactorachievedbythe

rate-monotonicpriorityassignmentforagiventasksetisgreaterthanorequaltotheutilization

fac-torforanyotherpriorityassignmentforthattaskset. Thus,theleastupperboundtobedetermined

is the in mum ofthe utilization factors corresponding to the rate-monotonic priority assignment

overallpossiblerequestperiodsandrun-timesforthetasks. Theboundis rstdeterminedfortwo

tasks, thenextendedforanarbitrarynumberoftasks.

Theorem3 For a set of two tasks with xed priority assignment, the least upper bound to the

processorutilization factorisU =2(2 1

2

(6)

1 2 1 2 1

and C

2

,respectively. Assumethat T

2 >T

1

. Accordingtotherate-monotonicpriorityassignment,



1

hashigherprioritythan

2

. Inacriticaltimezone of

2 , therearedT 2 =T 1 erequestsfor 1 . Let us now adjust C 2

to fully utilize the available processortime within thecritical time zone. Two

casesoccur:

Case1. Therun-timeC

1

isshortenoughthatallrequestsfor

1

within thecriticaltimezoneof

T

2

arecompletedbeforethesecond

2

request. Thatis,

C 1 T 2 T 1 bT 2 =T 1 c:

Thus,thelargestpossiblevalueofC

2 is C 2 =T 2 C 1 dT 2 =T 1 e:

Thecorrespondingprocessorutilizationfactoris

U =1+C 1 [(1=T 1 ) (1=T 2 )dT 2 =T 1 e]:

Inthiscase,theprocessorutilization factorU ismonotonicallydecreasingin C

1 .

Case 2. Theexecution of thedT

2 =T

1

eth request for 

1

overlapsthesecond request for 

2 . In this case C 1 T 2 T 1 bT 2 =T 1 c:

It followsthatthelargestpossiblevalueofC

2 is C 2 = C 1 bT 2 =T 1 c+T 1 bT 2 =T 1 c

andthecorrespondingutilization factoris

U =(T 2 =T 1 )bT 2 =T 1 c+C 1 [(1=T 1 ) (1=T 2 )bT 2 =T 1 c]:

Inthiscase,U ismonotonicallyincreasinginC

1 .

TheminimumofU clearlyoccursat theboundarybetweenthese twocases. Thatis,for

C 1 =T 2 T 1 bT 2 =T 1 c wehave U =1 (T 1 =T 2 )[dT 2 =T 1 e (T 2 =T 1 )][(T 2 =T 1 ) bT 2 =T 1 c]: (3)

Fornotationalconvenience, 3 letI =bT 2 =T 1 candf =fT 2 =T 1

g. Equation(3)canbewritten as

U =1 f(1 f)=(I+f):

Since U is monotonic increasing with I, minimum U occurs at the smallestpossible value of I,

namely, I =1. Minimizing U overf, wedetermine that at f = 2 1

2

1, U attains its minimum

valuewhichis

U =2(2 1

2

1)'0:83:

Thisis therelationwedesiredtoprove. 2

It shouldbenotedthat theutilization factorbecomes1iff =0,i.e. iftherequest period for

thelowerprioritytaskisamultipleoftheothertask'srequestperiod.

Wenowderivethecorrespondingbound foranarbitrarynumberoftasks. Atthismoment,let

usrestrictourdiscussiontothecaseinwhichtheratiobetweenanytworequestperiodsislessthan

2.

Theorem4 Forasetofmtaskswith xedpriorityorder,andtherestrictionthattheratiobetween

any two request periods is less than 2, the least upper bound to the processor utilization factor is

U =m(2 1=m 1). 3 fT 2 =T 1 gdenotes(T 2 =T 1 ) bT 2 =T 1

c,i.e. thefractionalpartofT

2 =T

(7)

1 2 m 1 2 m

tasks that fully utilize the processorand minimize the processor utilization factor. Assume that

T m >T m 1 >>T 2 >T 1

. LetU denotetheprocessorutilizationfactor. Wewishto showthat

C 1 =T 2 T 1 : Supposethat C 1 =T 2 T 1 +; >0: Let C 0 1 = T 2 T 1 C 0 2 = C 2 + C 0 3 = C 3 . . . C 0 m 1 = C m 1 C 0 m = C m : Clearly, C 0 1 , C 0 2 , , C 0 m 1 , C 0 m

also fully utilizethe processor. Let U 0

denote the corresponding

utilization factor. Wehave

U U 0 =(=T 1 ) (=T 2 )>0:

Alternatively,supposethat

C 1 =T 2 T 1 ; >0: Let C 00 1 = T 2 T 1 C 00 2 = C 2 2 C 00 3 = C 3 . . . C 00 m 1 = C m 1 C 00 m = C m : Again,C 00 1 ,C 00 2 ,,C 00 m 1 ,C 00 m

fullyutilizetheprocessor. LetU 00

denotethecorresponding

utiliza-tionfactor. Wehave

U U 00 = (=T 1 )+(2=T 1 )>0:

Therefore,ifindeedU istheminimumutilizationfactor,then

C 1 =T 2 T 1 :

Inasimilarway,wecanshowthat

C 2 = T 3 T 2 C 4 = T 4 T 3 . . . C m 1 = T m T m 1 : Consequently, C m =T m 2(C 1 +C 2 ++C m 1 ):

Tosimplify thenotation,let

(8)

C i =T i+1 T i =g i T i g i+1 T i+1 ; i=1;2;;m 1 and C m =T m 2g 1 T 1 and nally, U = m X i=1 (C i =T i )= m 1 X i=1 [g i g i+1 (T i+1 =T i )]+1 2g 1 (T 1 =T m ) = m 1 X i=1 [g i g i+1 (g i +1)=(g i+1 +1)]+1 2[g 1 =(g 1 +1)] = 1+g 1 [(g 1 1)=(g 1 +1)+ m 1 X i=1 g i [(g i g i 1 )=(g i +1)]: (4)

Justasin thetwo-taskcase,theutilization bound becomes1ifg

1

=0,foralli.

To ndtheleastupperboundtotheutilizationfactor,eq. (4)mustbeminimizedovertheg

j 's.

Thiscanbedonebysettingthe rstderivativeofU withrespecttoeachoftheg

j

'sequalto zero,

andsolvingtheresultantdi erenceequations:

@U=@g j =(g 2 j +2g j g j 1 )=(g j +1) 2 (g j+1 )=(g j+1 +1)=0; j=1;2;;m 1: (5) Thede nitiong 0

=1hasbeenadoptedforconvenience.

Thegeneralsolutiontoeqs. (5)canbeshowntobe

g j =s (m j)=m 1; j=0;1;;m 1: (6) It followsthat U =m(2 1=m 1);

whichistherelationwedesiredtoprove.

For m= 2,eq. (6) is the samebound aswasfound directly for the set of twotasks with no

restrictionontherequestperiods. Form=3,eq. (6)becomes

U =3(2 1=3

1)'0:78

andforlargem,U 'ln2. 2

The restriction that the largest ratio between request period less than 2 in Theorem 4 can

actuallyberemoved,whichwestateas:

Theorem5 For a set of m tasks with xed priority order, the least upper bound to processor

utilization isU =m(2 1=m 1). Proof. Let 1 , 2 ,, i ,, m

beasetofmtasksthatfullyutilizetheprocessor. LetU denote

the corresponding utilization factor. Suppose that for some i, bT

m =T i c > 1. Tobe speci c, let T m =qT i

+r, q >1and r0. Letus replace thetask 

i by atask 0 i , such that T 0 i =qT i and C 0 i =C i ,andincreaseC m

bytheamountneededtoagainfullyutilizetheprocessor. Thisincrease

isatmostC

i

(q 1),thetimewithinthecriticaltimezoneof

m occupiedby i ,butnotby 0 i . Let U 0

denote theutilization factorof suchasetoftasks. Wehave

U 0 <U +[(q 1)C i =T m ]+(C i =T 0 i ) (C i =T i ) or U 0 U+C i (q 1)[1=(qT i +r) (1=qT i )]: Sinceq 1>0and[1=(qT i +r) (1=qT i )]0,U 0

U. Thereforeweconcludethatindetermining

theleastupperbound oftheprocessorutilization factor,weneedonlyconsider tasksetsin which

the ratiobetween anytworequest periods is lessthan2. Thetheorem thusfollowsdirectly from

(9)

000000000000000000000000000000000

111111111111111111111111111111111

000000000000000000000000000000000

111111111111111111111111111111111

PROCESSOR

IDLE-PERIOD

REQUESTS FOR

TASK 2

REQUESTS FOR

TASK 3

REQUESTS FOR

TASK m

REQUESTS FOR

TASK 1

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

00

11

00

11

0

1

0

1

00

11

00

11

0

1

00

11

00

11

0

1

0

1

0

1

0

1

t

3

t

2

t

1

...

.

a

b

c

m

0

Figure3: Processingover owfollowingaprocessoridleperiod

6 Relaxing the Utilization Bound

The preceding section showed that the least upper bound imposed upon processorutilization by

therequirementforreal-timeguaranteedservicecanapproachln2forlargetasksets. Itisdesirable

to nd ways to improvethis situation,since the practical costsof switching between tasks must

still becounted. Oneof thesimplest waysofmaking theutilization bound equalto 1is to make

fT

m =T

i

g=0fori =1;2;;m 1. Since this cannotalwaysbe done,an alternativesolution is

to bu er task 

m

and perhaps several of the lowerpriority tasks and relax their hard deadlines.

Supposing that theentiretaskset hasa niteperiodand that thebu ered tasksare executedin

some reasonable fashion | e.g. in a rst come rst served fashion | then the maximum delay

timesandamountofbu eringrequiredcanbecomputedundertheassumptionsofthispaper.

A bettersolutionis to assigntask priorities insomedynamic fashion. Theremaining sections

ofthispaperaredevotedtooneparticularmethodofdynamicpriorityassignment. Thismethodis

optimuminthesensethatifasetoftaskscanbescheduledbysomepriorityassignment,itcanalso

be scheduledbythis method. Inother words, theleast upperbound onthe processorutilization

factorisuniformly100percent.

7 The Deadline Driven Scheduling Algorithm

Weturnnowtostudyadynamicschedulingalgorithmwhichwecallthedeadlinedrivenscheduling

algorithm. Usingthisalgorithm,prioritiesareassigned totasksaccordingtothedeadlinesoftheir

currentrequests. A taskwill beassignedthe highestpriorityifthedeadlineofitscurrentrequest

is thenearest,and willbeassignedthelowestifthedeadlineofitscurrentrequestisthefurthest.

Atanyinstant,thetask with thehighestpriorityand yet ful lled request willbeexecuted. Such

a method ofassigning priorities to the tasksis adynamic one,in contrastto astatic assignment

in which priorities of tasks donot change with time. Wewant nowto establish anecessaryand

suÆcientconditionforthefeasibilityofthedeadlinedrivenschedulingalgorithm.

Theorem6 Whenthe deadlinedriven scheduling algorithm isusedtoschedule asetof tasksona

processor, thereisnoprocessor idletimeprior toanover ow.

Proof. Suppose thatthere isprocessoridle timepriortoanover ow. Tobespeci c,startingat

time0,lett

3

denotethetimeatwhich anover owoccurs,andlett

1 ,t

2

(10)

0

1

00

11

a

2

00

11

0

1

a

3

0

1

b

1

00

11

00

11

00

11

00

11

b

2

000000000000000000000000000000

111111111111111111111111111111

0

1

0

1

b

3

...

00

11

00

11

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

a

1

0

T

Figure4: Processingover owattimeT

the end,respectively,oftheprocessoridle period closestto t

3

(i.e. there isnoprocessoridletime

betweent

2 andt

3

). ThissituationisillustratedinFigure3,wherethetimesofthe rstrequestfor

eachofthemtasksaftertheprocessoridle period[t

1 ;t

2

]aredenoted a;b;;m.

Supposethatfromt

2

onwemoveallrequestsoftask1upsothat awillcoincidewitht

2 . Since

there wasno processoridle time betweent

2 and t

3

, therewill benoprocessoridle timeafter a is

movedup. Moreover,anover owwilloccureither at orbefore t

3

. Repeating thesameargument

forallothertasks,weconcludethatifalltasksareinitiatedatt

2

,therewillbeanover owwithno

processoridle period priorto it. However, thisis acontradictionto theassumption that starting

at time0thereisaprocessoridle periodtoanover ow. ThisprovesTheorem6. 2

Theorem6will nowbeusedto establishthefollowingtheorem:

Theorem7 Foragiven setof mtasks, the deadlinedrivenscheduling algorithm isfeasibleif and

only if (C 1 =T 1 )+(C 2 =T 2 )++(C m =T m )1:

Proof. Toshowthenecessity,thetotaldemand ofcomputation timebyalltasks betweent=0

andt=T 1 T 2 T m ,maybecalculatedtobe (T 2 T 3 T m )C 1 +(T 1 T 3 T m )C 2 ++(T 1 T 2 T m 1 )C m :

Ifthetotaldemandexceedstheavailableprocessortime, i.e.

(T 2 T 3 T m )C 1 +(T 1 T 3 T m )C 2 ++(T 1 T 2 T m 1 )C m >T 1 T 2 T m (7) or (C 1 =T 1 )+(C 2 =T 2 )++(C m =T m )>1;

there isclearlynofeasibleschedulingalgorithm.

ToshowthesuÆciency,assumethatthecondition

(C 1 =T 1 )+(C 2 =T 2 )++(C m =T m )1

is satis edandyet theschedulingalgorithm isnotfeasible. That is, thereis anover owbetween

t=0andt=T 1 T 2 T m

. Moreover,accordingtoTheorem6thereisat=T(0T T

(11)

0

1

00

11

a

2

00

11

0

1

a

3

0

1

b

1

00

11

00

11

00

11

00

11

b

2

000000000000000000000000000000

111111111111111111111111111111

0

1

0

1

b

3

REQUESTS WITH DEALINES AT AND

WERE FULFILLED BEFORE

a

a

T ’

1

3

00

11

00

11

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

a

1

T ’

T

0

Figure5: Processingover owat timeT withoutexecutionoffb

i

gfollowingT 0

at which thereisanover owwithnoprocessoridletimebetweent=0andt=T. Tobespeci c,

let a 1 , a 2 , , b 1 , b 2

, , denote therequest timesof them tasks immediatelyprior to T,where

a

1 ,a

2

, aretherequest timesoftaskswithdeadlinesat T,and b

1 ,b

2

, aretherequest times

oftaskswithdeadlinesbeyondT. Thisisillustratedin Figure4.

Twocasesmustbeexamined.

Case1. Noneofthecomputationsrequestedatb

1 ,b

2

,wascarriedoutbeforeT. Inthiscase,

thetotaldemandofcomputationtime between0andT is

bT=T 1 cC 1 +bT=T 2 cC 2 ++bT=T m cC m :

Sincethere isnoprocessoridleperiod,

bT=T 1 cC 1 +bT=T 2 cC 2 ++bT=T m cC m >T:

Also,sincexbxcforallx,

(T=T 1 )C 1 +(T=T 2 )C 2 ++(T=T m )C m >T and (C 1 =T 1 )+(C 2 =T 2 )++(C m =T m )>1; whichisacontradictionto(7).

Case2. Someof thecomputationsrequestedat b

1 , b

2

,were carriedoutbefore T. Since an

over owoccursat T,there mustexist apointT 0

such thatnoneof therequestsat b

1 ,b

2

,  was

carriedoutwithin theintervalT 0

tT. Inotherwords,within T 0

tT,onlythose requests

with deadlinesat orbefore T willbeexecuted, asillustratedin Figure5. Moreover,thefact that

oneormoreof thetasks havingrequests at theb

i

's is executeduntil t =T 0

meansthat allthose

requests initiatedbefore T 0

withdeadlinesat orbeforeT havebeenful lled beforeT 0

. Therefore,

thetotaldemandofprocessortimewithinT 0

tT islessthanorequalto

b(T T 0 )=T 1 cC 1 +b(T T 0 )=T 2 cC 2 ++b(T T 0 )=T m cC m :

That anover owoccursatT meansthat

(12)

(C 1 =T 1 )+(C 2 =C 2 )++(C m =T m )>1;

andwhichisacontradictionto(7). Thisprovesthetheorem. 2

As was pointed out above, the deadline driven schedulingalgorithm is optimum in the sense

thatifasetoftaskscanbescheduledbyanyalgorithm,itcanbescheduledbythedeadlinedriven

schedulingalgorithm.

8 A Mixed Scheduling Algorithm

In thissectionweinvestigateaclass ofschedulingalgorithmswhich arecombinationsof the

rate-monotonicschedulingalgorithmandthedeadlinedrivenschedulingalgorithm.Wecallanalgorithm

inthisclassamixedschedulingalgorithm. Thestudyofthemixedschedulingalgorithmismotivated

by the observation that the interrupt hardware of present day computersacts asa xed priority

scheduleranddoesnotappeartobecompatiblewithahardwaredynamicscheduler. Ontheother

hand,thecostof implementing asoftwarescheduler fortheslowerpaced tasksisnotsigni cantly

increased if these tasks are deadline driven insteadof having a xed priority assignment. Tobe

speci c,let tasks1, 2,, k, thek tasksof shortestperiods, be scheduledaccordingto the xed

priorityrate-monotonicschedulingalgorithm, andletthe remainingtasks,tasks k+1,k+2,,

m, bescheduledaccordingto thedeadline drivenschedulingalgorithm when theprocessoris not

occupiedbytasks1,2,,k.

Leta(t)beanondecreasingfunctionoft. Wesaythata(t)issublinearifforalltandallT

a(T)a(t+T) a(t)

The availabilityfunction of aprocessorfor aset of tasksis de ned asthe accumulatedprocessor

time from 0 to t available to this set of tasks. Suppose that k tasks have been scheduled on a

processorbya xedpriorityschedulingalgorithm. Leta

k

(t)denotetheavailabilityfunctionofthe

processorfortasks k+1,k+2,, m. Clearly, a

k

(t)is anondecreasingfunction of t. Moreover,

a

k

(t)canbeshowntobesublinearbymeansofthecriticaltimezoneargument. Wehave:

Theorem8 If aset of tasks are scheduled by the deadline drivenscheduling algorithm on a

pro-cessorwhoseavailability functionissublinear, thenthereisnoprocessoridleperiodtoanover ow.

Proof. Similarto thatofTheorem6. 2

Theorem9 AnecessaryandsuÆcientconditionforthefeasibilityofthedeadlinedrivenscheduling

algorithm with respect toaprocessorwith availabilityfunction a

k (t)is bt=T k +1 cC k +1 +bt=T k +2 cC k +2 ++bt=T m cC m a k (t)

for all t'swhich are multiplesofT

k +1 ,orT k +2 ,,or T m .

Proof. Theproof is quitesimilar to that ofTheorem 7. Toshow thenecessity, observethat at

anymomentthetotaldemand ofprocessortimecannot exceedthetotalavailable processortime.

Thuswemusthave

(13)

thereisanover owatT. ExaminethetwocasesconsideredintheproofofTheorem7. Forcase1, bT=T k +1 cC k +1 +bT=T k +2 cC k +2 ++bT=T m cC m >a k (T);

which isacontradiction tothe assumption. Notethat T ismultiple of T

k +1 , orT k +2 ,, orT m . Forcase2, b(T T 0 )=T k +1 cC k +1 +b(T T 0 )=T k +2 cC k +2 ++ b(T T 0 )=T m cC m >a k (T T 0 )

Letbethesmallestnonnegativenumbersuchthat T T 0  isamultiple ofT k +1 ,orT k +2 ,, or T m . Clearly, b(T T 0 )=T k +j c=b(T T 0 )=T k +j c foreachj =1;2;;m k andthus b(T T 0 )=T k +1 cC k +1 +b(T T 0 )=T k +2 cC k +2 ++ b(T T 0 )=T m cC m >a k (T T 0 )a k (T T 0 );

whichisacontradictiontotheassumption. This provesthetheorem. 2

AlthoughtheresultinTheorem9isausefulgeneralresult,itsapplicationinvolvesthesolution

of a large set of inequalities. In any speci c case, it may be advantageous to derive suÆcient

conditions on schedule feasibility rather than work directly from Theorem 9. As an example,

considerthespecialcaseinwhichthreetasksarescheduledbythemixedschedulingalgorithmsuch

that thetask with theshortestperiod isassigned a xedand highestpriority, and theother two

tasksarescheduledbythedeadlinedrivenschedulingalgorithm. Itmaybereadilyveri edthatif

1 (C 1 =T 1 ) min[(T 1 C 1 )=T 2 ;(C 1 =T 1 )](C 2 =T 2 )+(C 3 =T 3 );

thenthemixed schedulingalgorithmis feasible. Itmaybealsoveri edthat if

C 2 a 1 (T 2 ); bT 3 =T 2 cC 2 +C 3 a 1 (bT 3 =T 2 cT 2 ); and (bT 3 =T 2 c+1)C 2 +C 3 a 1 (T 3 );

thenthemixed schedulingalgorithmis feasible.

Theproofofthesestatementsconsistsofsomerelativelystraightforwardbutextensiveinequality

manipulation,andmaybefoundinLiu[13]. Unfortunately,bothofthesesuÆcientconditions

cor-respondtoconsiderablylowerprocessorutilizationthandoesthenecessaryandsuÆcientcondition

ofTheorem 9.

9 Comparison and Comment

The constraintsin Theorem 9stronglysuggestthat 100percent utilization is notachievable

uni-versallybythemixed schedulingalgorithm. Thefollowingsimpleexamplewill illustratethis. Let

T 1 = 3, T 2 = 4, T 3 = 5, and C 1 = C 2 = 1. Since a 1

(20) = 13, it can be easily seen that the

maximumallowableC

3

is2. Thecorrespondingutilization factoris

U = 1 3 + 1 4 + 2 5 =98:3%:

If thesethree tasksare scheduledby thedeadlinedrivenschedulingalgorithm, C

2

canincreaseto

2.0833andachievea100percentutilization. Iftheyareallscheduledbythe xedpriority

rate-monotonicschedulingalgorithm,C

3

isrestrictedto1orless,andtheutilizationfactorisrestricted

(14)

Although aclosed form expression for the least upper bound to processor utilization has not

beenfound for themixed schedulingalgorithm, thisexample stronglysuggeststhat the bound is

considerably less restrictive for the mixed scheduling algorithm than for the xed priority

rate-monotonic scheduling algorithm. The mixed scheduling algorithm may thus be appropriate for

manyapplications.

10 Conclusion

In the initial parts of this paper, ve assumptions were made to de ne the environment which

supportedtheremaininganalyticalwork. Perhapsthemostimportantandleastdefensibleofthese

are (A1),that alltaskshaveperiodic requests,and (A4),that run-times areconstant. Ifthese do

nothold,thecriticaltimezoneforeachtaskshouldbede nedasthetimezonebetweenitsrequest

anddeadlineduringwhichthemaximumpossibleamountofcomputationisperformedbythetasks

havinghigher priority. Unless detailed knowledge of therun-timeand request are available,

run-abilityconstraintsontaskrun-timeswouldhavetobecomputedonthebasisofassumedperiodicity

andconstantrun-time,usingaperiodequaltotheshortestrequestintervalandarun-timeequalto

thelongest run-time. Noneof ouranalyticwork would remainvalidunder thiscircumstance,and

asevere bound onprocessorutilization couldwellbe imposed by thetaskaperiodicity. The xed

priorityordering now is monotonicwith the shortestspan betweenrequest and deadlinefor each

taskinsteadofwiththeunde nedrequestperiod. Thesamewillbetrueifsomeofthedeadlinesare

tighterthan assumedin(A2), although theimpactonutilization will beslightifonlythehighest

prioritytasksareinvolved. Itwouldappearthatthevalueoftheimplicationsof(A1)and(A4)are

great enoughto makethem adesign goal forany real-time tasks which must receive guaranteed

service.

Inconclusion,thispaperhasdiscussedsomeoftheproblemsassociatedwithmultiprogramming

inahard-real-timeenvironmenttypi edbyprocesscontrolandmonitoring,usingsomeassumptions

which seem to characterize that application. A scheduling algorithm which assigns priorities to

tasks in a monotonic relation to their request rates was shown to be optimum among the class

of all xed priorityschedulingalgorithms. The least upperbound to processorutilization factor

for this algorithm is onthe order of 70percentfor largetask sets. Thedynamic deadline driven

schedulingalgorithmwasthenshowntobegloballyoptimumandcapableofachievingfullprocessor

utilization. A combination of thetwo scheduling algorithms was then discussed; this appears to

providemost of thebene tsof thedeadline driven schedulingalgorithm, and yet may bereadily

implementedinexisting computers.

References

[1] Manacher, G. K. Production and stabilizationof real{time task schedules. J. ACM 14, 3

(July1967),439{465.

[2] McKinney, J.M.Asurveyofanalyticaltime-sharingmodels.ComputingSurveys1,2(June

1969),105{116.

[3] Codd,E.F.Multiprogrammingscheduling.Comm.ACM3,6,7(June,July1960),347{350;

413{418.

[4] Heller, J.Sequencingaspectsofmultiprogramming.J.ACM8,3(July1961),426{439.

[5] Graham, R. L. Bounds for certain multiprocessing anomalies. Bell System Tech. J. 45, 9

(Nov.1966),1563{1581.

[6] Oschner,B. P.,andCoffman, E. G.,Jr.Controllingamultiprocessorsystem.BellLabs

(15)

multiprocessorsystems.J.ACM 17,2(Apr. 1970),324{338.

[8] Bernstein, A. J..,and Sharp,J. C.Apolicy{drivenschedulerforatime{sharingsystem.

Comm. ACM14,2(Feb.1971),74{78.

[9] Lampson, B. W. A schedulingphilosophy for multiprocessing systems. Comm. ACM 11, 5

(May, 1968),347{360.

[10] Martin, J.ProgrammingReal-Time ComputerSystems.Prentice{Hall,EnglewoodCli s,N.

J.,1965.

[11] Jirauch, D. H.Softwaredesign techniques for automaticcheckout.IEEE Trans. AES 3, 6

(Nov.1967),934{940.

[12] Martin, J.Op.cit.,p.35 .

[13] Liu, C. L. Scheduling algorithms for hard-real-time multiprogramming of a single

proces-sor.JPL SpacePrograms Summary37{60,Vol.II,Jet PropulsionLab., Calif. Inst.of Tech.,

References

Related documents

Copyright for the publications made accessible via the Edinburgh Research Explorer is retained by the author(s) and / or other copyright owners and it is a condition of accessing

In order to explore teachers’ purposes for and methods of using their personal writing as models, and to investigate whether teachers experience any benefits and

Mean responses of perceived Appropriateness across Diagnosis, Education, Living in the Community, Family Life and Managing Transitions themed sections 81.

Tool Step 1 ECETOC TRA Step 2 GES Step 3 individual ES eSDS (BASIS) Standards, Ref. GES) BASF? ECHA? PBT-Tool.. Step Generic exposure assessment 3. Step Specific exposure assessment

Optimization of the mixed model processor scheduling (OMMPS) is nothing but allocating the processor time to the number of process using mixed model of processor scheduling (MMPS)

In such a system, the Cortex-M processor can also access to shared peripherals. Potentially some of the I/O control tasks can be off loaded to the Cortex-M processor so that the

Scheduling Test: - A scheduling test is a method to test the particular application, whether it is completed within the given deadline when the jobs or tasks are scheduled as

To evaluate the dissertation and the public defence thereof, the Faculty appoints an expert evaluation committee consisting of at least three members, based on the