Vous êtes sur la page 1sur 214

CSE3141Realtimesystemdesign

Lecturer:Dr.RonaldPose
Noprescribedtextbook
Coursematerialdefinedbylecturesandmaterialcontained
hereordistributedatlectures.Theexaminationwillonly
containmaterialcoveredinlectures.Thissubjectdiffers
considerablyfromthatgivenin2000.
Materialpresentedhereisderivedfrom
RealTimeSystemsbyJaneW.S.Liu.
Thisbookdoesnotcoverallthematerialforthissubject
andwewillnotcoveragreatdealofthisdetailedbook.
Someassignmentsorlabexerciseswillbescheduledlatein

thesemester.

Realtimesystemdesign
Outlineoftopics

Typicalrealtimeapplications
Digitalcontrol
Sampleddatasystems

Highlevelcontrols
Planningandpolicyabovelowlevelcontrol

Signalprocessing
Digitalfiltering,videocompression&encryption,radar
signalprocessing

Otherrealtimeapplications
Realtimedatabases,multimediaapplications

Hardversussoftrealtimesystem
JobsandProcessors
ReleaseTimes,Deadlines,andTiming
Constraints
HardandSoftTimingConstraints
HardRealTimeSystems
SoftRealTimeSystems

AModelofRealTimeSystems

ProcessorsandResources
TimingParametersofRealTimeWorkload
PeriodicTaskModel
PrecedenceConstraintsandDataDependency
OtherTypesofDependencies
ResourceParameters
SchedulingHierarchy

ApproachestoRealTime
Scheduling

ClockDrivenApproach
WeightedRoundRobinApproach
PriorityDrivenApproach
DynamicversusStaticSystems
EffectiveReleaseTimesandDeadlines
EarliestDeadlineFirst(EDF)Algorithm
LeastSlackTimeFirst(LST)Algorithm
ValidationofSchedules

ClockDrivenScheduling

Static,TimerDrivenScheduler
CyclicSchedules
AperiodicJobs
SchedulingSporadicJobs
AlgorithmstoConstructStaticSchedules
Advantages/DisadvantagesofClock
DrivenScheduling

PriorityDrivenSchedulingof
PeriodicTasks

FixedversusDynamicPriorityAlgorithms
MaximumSchedulableUtilization
RateMonotonicAlgorithms
DeadlineMonotonicAlgorithms
SchedulabilityTests

SchedulingAperiodicand
SporadicJobsinPriorityDriven
Systems
DeferableServers
SporadicServers
ConstantUtilization,TotalBandwidth,and
WeightedFairQueueingServers
SlackStealinginDeadlineDrivenSystems
SlackStealinginFixedPrioritySystems
SchedulingofSporadicJobs
ATwoLevelSchedulingScheme

ResourcesandResourceAccess
Control
EffectsofResourceContentionandResource
AccessControl
NonpreemptiveCriticalSections
PriorityInheritanceProtocol
PriorityCeilingProtocol
PreeemptionCeilingProtocol
ControllingAccesstoMultipleResources
ControllingConcurrentAccess

MultiprocessorScheduling,
ResourceAccessControl,and
Synchronization

MultiprocessorsandDistributedSystems
TaskAssignment
MultiprocessorPriorityCeilingProtocol
SchedulingforEndtoEndPeriodicTasks
SchedulabilityofFixedPriorityEndtoEnd
PeriodicTasks
EndtoEndTasksinHeterogeneousSystemsand
DynamicMultiprocessors

RealTimeCommunication

ModelofRealTimeCommunication
PriorityBasedServiceforSwitchedNetworks
WeightedRoundRobinService
MediumAccessControlProtocolsof
BroadcastNetworks
InternetandResourceReservationProtocols
RealTimeProtocol

OperatingSystems

TimeServicesandSchedulingMechanisms
OtherBasicOperatingSystemFunctions
ResourceManagement
CommercialRealTimeOperatingSystems
PredictabilityofGeneralPurposeOperating
Systems

WhatgoesoninaRealTime
OperatingSystem

RealTimeOperatingSystemKernelDesign
ShouldIuseaRealTimeKernel?
ShouldIbuildmyown?
ShouldIdistributethesystem?
CanIhaveaccesstotheunderlyinghardwareor
mustImaketowithanexistingoperating
system?
HowcanIdealwithasharedsystem?

TheOverallRealTimeSystem

MixingRealTimeandOtherJobs
ApproachestoRealTimeSystemDesign
SpecifyingRequiredPerformance
TestingandValidatingtheSystem
WhattodoifSpecificationsarenotmetor
cannotbemet

Summary
Summarizeandrevisetheimportanttopics
LookatSampleExaminationQuestions
ExaminetheLaboratoryAssignmentstosee
howtheyfitintotheframeworkdiscussed
inlectures

DigitalControlApplications
Manyrealtimesystemsareembeddedinsensorsandactuators
andfunctionasdigitalcontrollers.
Thestateofthecontrolledsystemismonitoredbysensorsandcan
bechangedbyactuators.
Therealtimecomputingsystemestimatesfromthesensor
readingsthecurrentstateofthesystemandcomputesacontrol
outputbasedonthedifferencebetweenthecurrentstateandthe
desiredstate.
Thecomputedoutputcontrolstheactuatorswhichbringthe
systemclosertothedesiredstate.

SampledDataSystems
Beforedigitalcomputerswerewidelyused,
analoguecontrollerswereusedtocontrolsystems.
Acommonapproachtodesigningadigital
controlleristostartwithasuitableanalogue
controller.
Theanalogueversionistransformedintoadigital
(discretetime,discretestate)version.
Theresultantcontrollerisasampleddatasystem.

InsideaSampledDataSystem
Periodicallytheanaloguesensorsaresampled
(read)andthereadingsdigitized.
Eachperiodthecontrollawcomputationsare
carriedoutonthedigitizedreadings.
Thecomputeddigitalresultsarethenconverted
backtoananalogueformneededfortheactuators.
Thissequenceofoperationsisrepeated
periodically.

ComputingtheControlLawfora
SampledDataSystem
Manycontrolsystemsrequireknowledgeofnotjust
thecurrentsensorreadings,butalsosomepasthistory.
Forinstanceitmaybenecessarytoknownotonlythe
positionofsomepartofthecontrolledsystem,butalso
itsvelocityandperhapsitsacceleration.
Oftenthecontrollawsmaytaketheformof
differentialequations.Itmaybenecessarytohave
derivativesorintegralsofmeasuredreadings.

IntegratingandDifferentiating
theDigitizedSensorInputs
Inordertocomputeanapproximationtothederivativeof
thesensorinputitisnecessarytokeepaseriesofpast
readings.Itmayalsobenecessarytokeepaseriesofpast
derivativevaluessoastoapproximatethe2ndderivative.
Forinstanceifoneknowsthetimebetweensamples,one
cancalculatefromthedifferencebetweensuccessive
sampledpositions,aninstantaneousvelocity,andfromthe
differencebetweensuccessivevelocities,anacceleration.

Integration
Justaswecanapproximatethederivativesof
varioussampledvalues,sowecanalso
approximateintegrals.
Todothiswecanusevariousnumerical
integrationalgorithmssuchasasimpletrapezoidal
method.
Sogivenastartingpositionandsomepastand
currentaccelerationandvelocitieswecan
approximatethecurrentposition.

AFeedbackControlLoop
settimertointerruptperiodicallywithperiodT;
ateachtimerinterruptdo
doanaloguetodigitalconversion
computecontroloutput
dodigitaltoanalogueconversion

enddo
Wehaveassumedthatthesystemprovidesatimer.

SelectionofSamplingPeriod
ThelengthToftimebetweenanytwoconsecutiveinstantsatwhichthe
inputsaresamplediscalledthesamplingperiod.
Tisakeydesignchoice.
Thebehaviourofthedigitalcontrollercriticallydependsonthis
parameter.
Ideallywewantthesampleddataversiontobehaveliketheanalogue
controllerversion.
ThiscanbedonebymakingTverysmall.
Howeverthisincreasesthecomputationrequired.
Weneedagoodcompromise.

ChoosingtheSamplingPeriod
Weneedtoconsidertwofactors:
Theperceivedresponsivenessoftheoverallsystem
Samplingintroducesadelayinthesystemresponse.
Ahumanoperatormayfeelthatthesystemissluggishifthedelay
inresponsetohisinputisgreaterthanaboutatenthofasecond.
Thusmanualsystemsmustnormallybesampledataratehigher
thantentimespersecond.

Thedynamicbehaviourofthesystem
Ifthesamplingrateistoolow,thecontrolloopmaynotbeableto
keeptheoscillationinitsresponsesmallenough.

Selectingsamplingratetoensure
dynamicbehaviourofthesystem
Ingeneral,thefasterasystemcanandmustrespond
tochanges,theshorterthesamplingperiodshould
be.
Wecanmeasuretheresponsivenessofthesystem
byitsrisetimeR.
Risthetimeittakestogetclosetoitsfinalstate
aftertheinputchanges.
TypicallyyouwouldliketheratioR/Tofrisetime
tosamplingperiodtobebetween10and20.

Samplingrate
Ashortersamplingperiodislikelytoreducetheoscillationinthe
systematthecostofmorecomputation.
Onecanalsoconsiderthisintermsofbandwidthwhichis
approximately1/2RHz.Sothesamplingrateshouldbe20to40
timesthebandwidth.
TheNyquistsamplingtheoremsaysthatanytimecontinuoussignal
ofbandwidthcanbereproducedfaithfullyfromitssampledvalues
onlyifthesamplingrateisatleast2.
Notethattherecommendedsamplingrateforsimplecontrollersis
muchhigherthanthisminimum.

Multiratesystems

Asystemtypicallyhasstatedefinedbymultiplestatevariables.
e.g.rotationspeed,temperature,fuelconsumption,etc.ofan
engine.
Thestateismonitoredbymultiplesensorsandcontrolledby
multipleactuators.
Differentstatevariableshavedifferentdynamicsandwillrequire
differentsamplingperiodstoachievesmoothresponse.e.g.the
rotationspeedwillchangefasterthanitstemperature.
Asystemwithmultiplesamplingratesiscalledamultirate
system.

Samplinginmultiratesystems
Inmultiratesystemsitisoftenusefultohavethe
samplingratesrelatedinaharmonicwaysothat
longersamplingperiodsareintegermultiplesof
shorterones.
Thisisusefulbecausethestatevariablesare
usuallynotindependent,andtherelationships
betweenthemcanbemodelledbetteriflonger
samplingperiodscoincidewiththebeginningof
theshorterones.

Timingcharacteristics
Theworkloadgeneratedbyeachmultivariate,multiratedigital
controllerconsistsofafewperiodiccontrollawcomputations.
Acontrolsystemmaycontainmanydigitalcontrollers,eachdealing
withpartofthesystem.
Togethertheydemandperhapshundredsofcontrollawsbe
computerperiodically,somecontinuously,othersinreactiontosome
events.
Thecontrollawsofeachmultiratecontrollermayhaveharmonic
periodsandtypicallyusethedateproducedbyeachotherasinputs,
andaresaidtobearategroup.

Controllawcomputationtiming
Eachcontrollawcomputationcanbegin
shortlyaftersampling.
Usuallyyouwantthecomputationcomplete,
hencethesensordataprocessed,beforethe
nextsensordatasamplingperiod.
Thisobjectiveismetwhentheresponsetime
ofeachcomputationneverexceedsthe
samplingperiod.

Jitter
Insomecasestheresponsetimeofthecomputation
canvaryfromperiodtoperiod.
Insomesystemsitisnecessarytokeepthis
variationsmallsothatdigitalcontroloutputsare
availableatinstantsmoreregularlyspacedintime.
Insuchcaseswemayimposeatimingjitter
requirementonthecontrollawcomputation.The
variationinresponsetime(jitter)doesnotexceed
somethreshold.

Morecomplexcontrollaw
computations

Thesimplicityofourdigitalcontrollerdependsonthree
assumptions:
1 Sensorsgiveaccurateestimatesofthestatevariablevaluesbeing
monitoredandcontrolled.Thisisnotalwaystruegivennoiseor
otherfactors.
2 Sensordatagivethestateofthesystem.Ingeneralsensors
monitorsomeobservableattributesandthevaluesofstatevariables
havetobecomputedfromthemeasuredvalues.
3 Allparametersrepresentingthedynamicsofthesystemare
known.

Amorecomplexdigitalcontroller
settimertointerruptpeiodicallywithperiodT;
Ateachclockinterruptdo
Sampleanddigitizesensorreadings;
Computecontroloutputfrommeasuredandstatevariablevalues;
Convertcontroloutputtoanalogueform;
Estimateandupdatesystemparameters;
Computeandupdatestatevariables;

Enddo;
Thelast2stepsintheloopincreaseprocessingtime.

HighLevelControls
Controllersincomplexsystemsaretypically
organizedhierarchically.
Oneormoredigitalcontrollersatthelowest
leveldirectlycontrolthephysicalsystem.
Eachoutputofahigherlevelcontrollerisan
inputofoneormorelowerlevelcontrollers.
Usuallyoneormoreofthehigherlevel
controllersinterfaceswiththeoperator.

Examplesofcontrolhierarchy

Apatientcaresysteminahospital.

Lowlevelcontrollershandlingbloodpressure,respiration,glucose,etc.
Highlevelcontroller,e.g.anexpertsystemwhichinteractswiththedoctorto
choosedesiredvaluesforthelowlevelcontrollerstomaintain.

Thehierarchyofflightcontrol,avionicsandairtrafficcontrolsystems.
Theairtrafficcontrolsystemisatthehighestlevel.
Theflightmanagementsystemchoosestheflightpathsetc.andsetsparameters
forthelowerlevelcontrollers.
Theflightcontrolleratthelowestlevelhandlescruisespeed,turnradius,
ascend/descendratesetc.

SignalProcessing
Mostsignalprocessingapplicationsarerealtime
requiringresponsetimesfromlessthana
milliseconduptoseconds.e.g.digitalfiltering,
videoandaudiocompression/decompression,and
radarsignalprocessing.
Typicallyarealtimesignalprocessing
applicationcomputesinonesamplingperiod,one
ormoreoutputs,eachbeingaweightedsumofn
inputs.Theweightsmayevenvaryovertime.

SignalProcessingBandwidth
Demands
Theprocessingtimedemandofanapplication
dependsonthesamplingperiodandhowmany
outputsarerequiredtobeproducedpersampling
period.
Fordigitalfilteringthesamplingratecanbetens
ofkHzandthecalculationmayinvolvetensor
hundredsofterms,hencetensofmillionsof
multiplicationsandadditionsmayberequiredper
second.

Morecomplexsignalprocessing
Whiledigitalfilteringisoftenalinear
computationdependingonthenumberofterms
intheexpression,othersignalprocessing
applicationsareevenmorecomputationally
intensive.
Forinstancerealtimevideocompressionmay
havecomplexityofordern2,andmayrequire
hundredsofmillionsofmultiplicationsper
second.

Radarsignalprocessing
Signalprocessingisusuallypartofalargersystem.e.g.apassive
radarsignalprocessingsystem.
ThesystemcomprisesanI/Osubsystemthatsamplesanddigitizes
theechosignalfromtheradarandplacesthesampledvaluesin
sharedmemory.Anarrayofdigitalsignalprocessorsprocess
thesevalues.Thedataproducedareanalyzedbyoneormoredata
processorswhichnotonlyinterfacetothedisplaysystembutalso
feedbackcommandstocontroltheradarandselectparametersfor
thesignalprocessorstobeusedforthenextsamplingperiod.

Realtimedatabases
Stockexchangepricedatabasesystems
Airtrafficcontroldatabases
Whatmakesitrealtime?

Thedataisperishable
Thedatavaluesareupdatedperiodically
Afterawhilethedatahasreducedvalue
Thereneedstobetemporalconsistencyaswellas
normaldataconsistency

AbsoluteTemporalConsistency
Realtimedatahasparameterssuchasageandtemporal
dispersion.
Theageofanobjectmeasureshowuptodatethe
informationis.
Theageofanobjectwhosevalueiscomputedfromother
objectsisequaltothatoftheoldestofthoseobjects.
Asetofdataobjectsissaidtobeabsolutelytemporally
consistentifthemaximumageinthesetisnogreater
thanacertainthreshold.

Relativetemporalconsistency
Asetofdataobjectsissaidtoberelatively
temporallyconsistentifthemaximum
differenceintheagesislessthanthe
relativeconsistencythresholdusedbythe
application.
Forsomeapplicationstheabsoluteageis
lessimportantthanthedifferencesinages.

Realtimedatabaseconsistency
models
Concurrencycontrolmechanismssuchas2phaselockinghave
beenusedtoensureserializabilityofreadandupdatetransactions
andmaintaindataintegrityofnonrealtimedatabases.
Thesemechanismscanmakeitmoredifficultforupdatestobe
completedintime.
Lateupdatesmaycausedatatobecometemporallyinconsistent.
Weakerconsistencymodelsaresometimesusedtoensurethe
timelinessofupdatesandreads.

ConsistencyModels
Forinstancewemayrequireupdatestobe
serializablebutallowreadonlytransactionsnot
tobeserializable.
Usuallythemorerelaxedtheserialization
requirement,themoreflexibilitythesystemhas
ininterleavingthereadandwriteoperationsfrom
differenttransactions,andtheeasieritisto
scheduletransactionssothattheycompletein
time.

Correctnessofrealtimedata
KuoandMokproposedthatsimilaritymaybea
suitablecorrectnesscriterioninsomerealtime
situations.
Twoviewsofatransactionaresimilarifevery
readoperationgetssimilarvaluesofeverydata
objectsreadbythetransaction,wheresimilar
meansthatthedatavaluesarewithinan
acceptablethresholdfromthepointofviewof
everytransactionthatmayreadtheobject.

Summaryofrealtimeapplications

1. Purelycyclic:
Everytaskexecutesperiodically.EvenI/O
operationsarepolled.Demandsonresourcesdonotvarysignificantly
fromperiodtoperiod.Mostdigitalcontrollersareofthistype.
2. Mostlycyclic:
Mosttasksexecuteperiodically.Thesystemcan
alsorespondtosomeexternaleventsasynchronously.
3. Asynchronousandsomewhatpredictable: Inapplicationssuchas
multimediacommunication,radarsignalprocessing,tracking,mosttasks
arenotperiodic.Durationbetweenexecutionsofataskmayvary
considerablyortheresourcerequirementsmayvary.Variationshave
boundedrangesorknownstatistics.
4. Asynchronousandunpredictable.

ReferenceModelofRealTime
Systems
Weneedareferencemodelofrealtime
systemstoallowustofocusonaspectsofthe
systemrelevanttoitsrealtimetimingand
resourceproperties.
Therearemanypossiblemodelsofrealtime
systems.
Wewillexamineanexamplebutitisnot
meanttobedefinitive.

Elementsofthereferencemodel
Eachsystemischaracterizedby3elements:
Aworkloadmodeldescribingtheapplications
supportedbythesystem
Aresourcemodeldescribingthesystem
resourcesavailabletotheapplications
Algorithmsthatdefinehowtheapplication
systemusestheresourcesatalltimes.

Useofareferencemodel
Ifwechoosetodosowecandescribeasystem
sufficientlyaccuratelyintermsofthereference
model,thatwecananalyze,simulate,andeven
emulateasystembasedonitsdescription.
Forsomerealtimesystemsweknowinadvance
theresourcesandapplicationswewanttorun.
Inothersystemsresourcesandtasksmaybe
addeddynamically.

Algorithmicpartofthereference
model
Firstwewilllookbrieflyatthedescription
ofresourcesandapplications,thefirsttwo
partsofthereferencemodel.
Thenwewillspendmuchoftherestofthe
timelookingatalgorithmsandmethodsto
enableustoproducesystemswhichhave
thedesiredrealtimecharacteristics.

ProcessorsandResources
Wedivideallthesystemresourcesintotwo
types:
processors(sometimescalledserversoractive
resourcessuchascomputers,datalinks,database
serversetc.)
otherpassiveresources(suchasmemory,sequence
numbers,mutualexclusionlocksetc.)

Jobsmayneedsomeresourcesinadditiontothe
processorinordertomakeprogress.

Processors
Processorscarryoutmachineinstructions,
movedata,retrievefiles,processqueriesetc.
Everyjobmusthaveoneormoreprocessors
inordertomakeprogresstowards
completion.
Sometimesweneedtodistinguishtypesof
processors.

Typesofprocessors
Twoprocessorsareofthesametypeiftheycanbe
usedinterchangeablyandarefunctionallyidentical.
Twodatalinkswiththesametransmissionratesbetween
thesametwonodesareconsideredprocessorsofthesame
type.Similarlyprocessorsinasymmetricmultiprocessor
systemareofthesametype.

Oneoftheattributesofaprocessorisitsspeed.We
willassumethattherateofprogressajobmakes
dependsonthespeedoftheprocessoronwhichitis
running.

Speed
Wecanexplicitlymodelthedependencyofjob
progressionandprocessorspeedbymakingthe
amountoftimeajobrequirestocompletea
functionoftheprocessorspeed.
Incontrastwedonotassociatespeedwitha
resource.
Howlongajobtakestocompletedoesnotdepend
onthespeedofanyresourceitusesduring
execution.

Exampleofajob(1)
Acomputationjobmaysharedatawithothers
computations,andthedatamaybeguardedby
semaphores.Eachsemaphoreisaresource.
Whenajobwantstoaccesstheshareddata
guardedbyasemaphoreR,itmustfirstlockthe
semaphore,thenitentersthecriticalsectionof
code.Inthiscasewesaythatthejobrequires
theresourceRforthedurationofthiscritical
section.

Exampleofajob(2)
Consideradatalinkthatusesaslidingwindowschemeforflow
control.Onlyamaximumnumberofmessagesareallowedtobein
transit.Onewaytoimplementthisistohavethesendermaintaina
windowofvalidsequencenumbers.Thewindowismovedforward
asmessagestransmittedearlierareacknowledgedbythereceiver.A
messageawaitingtransmissionmustbeallocatedoneofthevalid
sequencenumbersbeforetransmission.
Wemodelthetransmissionofthemessageasajobwhichexecutesas
themessageisbeingtransmitted.Thisjobneedsthedatalinkaswell
asavalidsequencenumber.Thedatalinkisaprocessoranda
sequencenumberisaresource.

Examplesofjobs(3)
Weusuallymodelqueryandupdatetransactions
todatabasesasjobs.Thesejobsexecuteona
databaseserver.Ifthedatabaseserverusesa
lockingmechanismtoensuredataconsistency
thenatransactionalsoneedslocksonthedata
objectsitreads/writesinordertoproceed.
Thelocksondataobjectsareresources.
Thedatabaseserverisaprocessor.

Resources
Resourcesintheexampleswerereusablesincetheywerenot
consumedduringuse.
Otherresourcesareconsumedduringuseandcannotbeused
again.
Someresourcesareseriallyreusable.Theremaybemanyunitsof
aserialresource,buteachcanonlybeusedbyonejobatatime,
Topreventourmodelbeingclutteredbyirrelevantdetailswe
typicallyomitresourceswhichareplentiful.
Aresourceisplentifulifnojobiseverpreventedfromrunningbythe
lackofthisresource.

Infiniteresources
Aresourcethatcanbesharedbyaninfinite
numberofjobsneednotbeexplicitlymodelled.
(e.g.afilethatisreadablesimultaneouslyby
everyone)
Memoryisclearlyanessentialresource,however
ifwecanaccountforthespeedofthememoryby
thespeedoftheprocessormemorycombination,
andifmemoryisnotabottleneck,wecanomitit
fromthemodel.

Memory
Forexample,wecanaccountforthespeed
ofbuffermemoryinacommunications
switchbylettingthespeedofeachlink
equalthetransmissionrateofthelinkorthe
rateatwhichdatacangetintooroutofthe
buffer,whicheverissmaller.

ProcessororResource?
Wesometimesmodelsomeelementsofthesystemas
processorsandsometimesasresources,dependingon
howweusethemodel.
Forexample,inadistributedsystemacomputationjob
mayinvokeaserveronaremoteprocessor.
Ifwewanttolookathowtheresponsetimeofthisjobis
affectedbythewaythejobisscheduledonitslocalprocessor,
wecanmodeltheremoteserverasaresource.
Wemayalsomodeltheremoteserverasaprocessor.

Modellingchoices

Therearenofixedrulestoguideusindecidingwhether
tomodelsomethingasaprocessororasaresource,orto
guideusinmanyothermodellingchoices.
Agoodmodelcangiveusbetterinsightintotherealtime
problemweareconsidering.
Abadmodelcanconfuseusandleadtoapoordesignand
implementation.
Inmanywaysthisisanartwhichrequiressomeskillbut
providesgreatfreedomfordesigningandimplementing
realtimesystems.

Temporalparametersofrealtime
workloads
Theworkloadonprocessorsconsistsofjobs,each
ofwhichisaunitofworktobeallocatedprocessor
timeandotherresources.
Asetofrelatedjobswhichcombinetosupporta
systemfunctionisatask.
Weassumethatmanyparametersofhardrealtime
jobsandtasksareknownatalltimes;otherwisewe
couldnotensurethatthesystemmeetsitsrealtime
requirements.

Realtimeworkloadparameters
Thenumberoftasksorjobsinthesystem.
Inmanyembeddedsystemsthenumberoftasksisfixedfor
eachoperationalmode,andthesenumbersareknownin
advance.
Insomeothersystemsthenumberoftasksmaychangeasthe
systemexecutes.
Nevertheless,thenumberoftaskswithhardtimingconstraints
isknownatalltimes.
Whenthesatisfactionoftimingconstraintsistobe
guaranteed,theadmissionanddeletionofhardrealtimetasks
isusuallydoneunderthecontroloftheruntimesystem.

Theruntimesystem
Theruntimesystemmustmaintain
informationonallexistinghardrealtime
tasks,includingthenumberofsuchtasks,
andalltheirrealtimeconstraintsand
resourcerequirements.

Thejob
EachjobJiischaracterizedbyitstemporal
parameters.
Itstemporalparameterstellusitstimingconstraints
andbehaviour.
Itsinterconnectionparameterstellushowitdepends
onotherjobsandhowotherjobsdependonit.
Itsfunctionalparametersspecifytheintrinsic
propertiesofthejob.

Jobtemporalparameters
ForjobJi
Releasetime ri
Absolutedeadline di
Relativedeadline Di
Feasibleinterval

(ri,di]

diandDiareusuallyderivedfromthetiming
requirementsofJi,otherjobsinthesametaskasJi,
andtheoverallsystem.
Theseparametersarepartofthesystemspecification.

Releasetime
Inmanysystemswedonotknowexactlywheneachjobwill
bereleased.
i.e.wedonotknowri
Weknowthatriisintherange[ri,ri+]
Ricanbeasearlyasriandaslateasri+
Somemodelsassumethatonlytherangeofriisknownandcallthis
range,releasetimejitter.
Ifthereleasetimejitterisverysmallcomparedwithothertemporal
parameters,wecanapproximatetheactualreleasetimebyits
earliestriorlatestri+releasetime,andsaythatthejobhasafixed
releasetime.

Sporadicjobs
Mostrealtimesystemshavetorespondto
externaleventswhichoccurrandomly.
Whensuchaneventoccursthesystemexecutes
asetofjobsinresponse.
Thereleasetimesofthosejobsarenotknown
untiltheeventtriggeringthemoccurs.
Thesejobsarecalledsporadicjobsoraperiodic
jobsbecausetheyarereleasedatrandomtimes.

Sporadicjobreleasetimes
Thereleasetimesofsporadicandaperiodicjobsarerandomvariables.
ThesystemmodelgivestheprobabilitydistributionA(x)ofthe
releasetimeofsuchajob.
Whenthereisastreamofsimilarsporadicoraperiodicjobsthemodel
providesaprobabilitydistributionofinterreleasetime,i.e.howlong
betweenthereleasetimesoftwoconsecutivejobsinthestream.
A(x)givesustheprobabilitythatthereleasetimeofajobisator
earlierthanx,orinthecaseofinterreleasetime,thatitislessthanor
equaltox.

Arrivaltimes
Ratherthanspeakingofreleasetimesfor
aperiodicjobs,wesometimesusetheterm
arrivaltime(orinterarrivaltime)whichis
commonlyusedinqueueingtheory.
Anaperiodicjobarriveswhenitisreleased.
A(x)isthearrivaltimedistributionor
interarrivaltimedistribution.

Executiontime
AnothertemporalparameterofajobJiisits
executiontime,ei.
eiisthetimerequiredtocompletetheexecutionofJi
whenitexecutesaloneandhasalltheresourcesit
requires.
Thevalueofeidependsmainlyonthecomplexityof
thejobandthespeedoftheprocessorusedto
executethejob.
eidoesnotdependonhowthejobisscheduled.

Jobexecutiontime

Theexecutiontimeofajobmayvaryformanyreasons.
Acomputationmaycontainconditionalbranchesandtheseconditional
branchesmaytakedifferentamountsoftimetocomplete.
Thebranchestakenduringtheexecutionofajobdependoninputdata.
Iftheunderlyingsystemhasperformanceenhancingfeaturessuchas
cachesandpipelines,theexecutiontimecanvaryeachtimeajob
executes,evenwithoutconditionalbranches.

Thustheactualexecutiontimeofacomputationaljobmaybe
unknownuntilitcompletes.

Characterizingexecutionntime
Whatcanbedeterminedthroughanalysisand
measurementarethemaximumandminimum
amountsoftimerequiredtocompleteeachjob.
WeknowthattheexecutiontimeeiofjobJiisinthe
range[ei,ei+]whereeiistheminimumexecution
timeandei+isthemaximumexecutiontimeofjobJi.
Weassumethatweknoweiandei+ofeveryhard
realtimejobJi,evenifwedontknowei.

Maximumexecutiontime
Forthepurposeofdeterminingwhethereachjobcan
alwayscompletebyitsdeadline,itsufficestoknowits
maximumexecutiontime.
Inmostdeterministicmodelsusedtocharacterizehard
realtimeapplications,thetermexecutiontimeeiofeach
jobJispecificallymeansitsmaximumexecutiontime.
Howeverwedontmeanthattheactualexecutiontimeis
fixedandknown,onlythatitneverexceedsourei(which
mayactuallybeei+)

Consequencesoftemporal
assumptions
Ifwedesignoursystembasedontheassumptionthateiis
ei+andallocatethismuchtimetoeachjob,theprocessors
willbeunderutilized.
Thisissometimestrue.
Insomeapplicationsthevariationsinjobexecutiontimes
aresolargethatworkingwiththeirmaximumvalues
yieldsunacceptablyconservativedesigns.
Weshouldnotmodelsuchapplicationsdeterministically.

Dangersofdeterministic
modelling
Insomesystemstheresponsetimesofsome
jobsmaybelargerwhentheactual
executiontimesofsomejobsaresmaller
thantheirmaximumvalues.
Inthesecasesweshallhavetodealwith
variationsinexecutiontimesexplicitly.

Usingdeterministicmodelling
Manyhardrealtimesystemsaresafetycritical.
Thesesystemsaredesignedandimplementedinsuchaway
thatthevariationsinjobexecutiontimesarekeptassmallas
possible.
Theneedtohaverelativelydeterministicexecutiontimes
imposesmanyimplementationrestrictions.
Useofdynamicdatastructurescanleadtovariableexecutiontime
andmemoryusage.
Performanceenhancingfeaturesmaybeswitchedoff.

Whyusethedeterministic

modellingapproach?
Byworkingwithintheserestrictionsandmakingtheexecutiontimesofjobs

almostdeterministic,thedesignercanmodelmoreaccuratelytheapplication
systemdeterministically.
Anotherreasontostickwiththedeterministicapproachisthatthehardreal
timeportionofthesystemisoftensmall.
Thetimingrequirementsoftherestofthesystemaresoft,soitmaybe
reasonabletoassumeworstcasemaximumvaluesforthehardrealtimeparts
ofthesystemsincetheoveralleffectonresourceswontbesodramatic.
Wecanthenusethemethodsandtoolsofthedeterministicmodelling
approachtoensurethathardrealtimeconstraintswillbemetatalltimesand
thedesigncanbevalidated.

PeriodicTaskModel
ThePeriodicTaskModelisadeterministic
workloadmodel.
Themodelaccuratelycharacterizesmany
traditionalhardrealtimeapplicationssuchas
digitalcontrol,realtimemonitoring,andconstant
bitratevoice/videotransmission.
Manyschedulingalgorithmsbasedonthismodel
havegoodperformanceandwellunderstood
behaviour.

Periods
Intheperiodictaskmodeleachcomputationordatatransmissionthatisexecuted
repeatedlyatregularoralmostregulartimeintervalsinordertoprovidea
functionofthesystemonacontinuingbasis,ismodelledasaperiodictask.
Eachperiodictask,Ti,isasequenceofjobs.
TheperiodpioftheperiodictaskTiistheminimumlengthofalltimeintervals
betweenreleasetimesofconsecutivejobsinTi.
Itsexecutiontimeisthemaximumexecutiontimeofallthejobsinit.
Wewillcheatanduseeitorepresentthisperiodictaskexecutiontimeaswellas
thatofallitsjobs.
Atalltimestheperiodandexecutiontimesofeveryperiodictaskinthesystem
areknown.

Notesaboutperiodictasks
Ourdefinitionofperiodictasksdiffersfromthestrict
onegiveninmanytextbooksandpapers.
Wewillallowourperiodictaskstohaveinterrelease
timesofallitsjobsnotalwaysequaltoitsperiod.
Someliteraturedescribestaskswithinterreleasetimes
ofallitsjobsnotequaltoitsperiodassporadictasks.
Forourpurposesasporadictaskisonewhose
interreleasetimescanbearbitrarilysmall.

PeriodicTaskModelAccuracy
Theaccuracyoftheperiodictaskmodeldecreaseswith
increasingjitterinreleasetimesandvariationsinexecution
times.
Thusaperiodictaskisaninaccuratemodelofavariablebit
ratevideobecauseofthelargevariationinexecutiontimes
ofjobs.
Aperiodictaskisalsoaninaccuratemodelofthe
transmissionofpacketsinarealtimeconnectionthrougha
switchednetworkbecauseofitslargereleasetimejitter.

Notation(1)
Wecallthetasksinthesystem
T1,T2,,Tn
wheretherearenperiodictasksinthesystem.ncanvary
asperiodictasksareaddedordeletedfromthesystem.
WecalltheindividualjobsinthetaskTi
Ji,1,Ji,2,,Ji,k
wheretherearekjobsinthetaskTi
Ifwewanttotalkaboutindividualjobsbutarenot
concernedaboutwhichtasktheyarein,wecancallthe
jobsJ1,J2,etc.

Notation(2)
Thereleasetimeri,1ofthefirstjobJi,1in
eachtaskTiiscalledthephaseofTi
WeuseitodenotethephaseofTi
Ingeneraldifferenttasksmayhavedifferent
phases.
Sometasksareinphase,meaningthatthey
havethesamephase.

Notation(3)
Hdenotestheleastcommonmultipleofpifori=1,
2,n
AtimeintervaloflengthHiscalledahyperperiod
oftheperiodictasks.
Themaximumnumberofjobsineachhyperperiod
isni=1H/pi
e.g.thelengthofahyperperiodfor3periodictasks
withperiods3,4and10is60,andthetotalnumber
ofjobsis41.

Notation(3)
Theratioui=ei/piiscalledtheutilizationofthetask
Ti
uiisthefractionoftimethatatrulyperiodictaskwith
periodpiandexecutiontimeeikeepsaprocessor
busy.
uiisanupperboundofutilizationforthetask
modelledbyTi
ThetotalutilizationUofalltasksinthesystemisthe
sumoftheui

Utilization
Iftheexecutiontimesofthethreeperiodic
tasksare1,1,and3,andtheirperiodsare
3,4,and10,thentheirutilizationsare0.33,
0.25and0.3
Thetotalutilizationofthesetasksis0.88
thusthesetaskscankeepaprocessorbusy
atmost88percentofthetime.

Morenotation
AjobinTithatisreleasedattimetmustcompleteDiunitsoftime
aftert
DiistherelativedeadlineofthetaskTi
Wewilloftenassumethatforeverytaskajobisreleasedand
becomesreadyatthebeginningofeachperiodandmustcomplete
bytheendoftheperiod.
InotherwordsDi=piforalln
Thisrequirementisconsistentwiththethroughputrequirement
thatthesystemcankeepupwithalltheworkrequiredatalltimes.

Moreaboutdeadlines
Dicanhaveanarbitraryvaluehoweveritmustbe
shorterthanpi
Givingataskashortrelativedeadlineisawayto
specifythatvariationsintheresponsetimeof
individualjobs(i.e.jitterintheircompletiontimes)
ofthetaskmustbesufficientlysmall.
Sometimeseachjobinataskmaynotbeready
whenitisreleased.Forexampleitmayhavetowait
foritsinputdatatobemadeavailableinmemory.

Moreaboutdeadlines(2)

Thetimebetweenthereadytimeofeachjobandtheendoftheperiod
isshorterthantheperiod.
Sometimestheremaybesomeoperationtobeperformedafterajob
completesbutbeforethenextjobisreleased.
Sometimesajobmaybecomposedofdependentjobswhichmustbe
executedinsequence.
Awaytoenforcesuchdependenciesistodelaythereleaseofajob
laterinthesequencewhileadvancingthedeadlineofajobearlierin
thesequence.
Therelativedeadlinesmayalsobeshortened.

AperiodicandSporadicTasks
Mostrealtimejobsarerequiredtorespondtoexternalevents,andto
respondtheyexecuteaperiodicorsporadicjobswhosereleasetimes
arenotknowninadvance.
Intheperiodictaskmodeltheworkloadgeneratedinresponseto
theseunexpectedeventstakestheformofaperiodicandsporadic
tasks.
Eachaperiodicorsporadictaskisastreamofaperiodicorsporadic
jobs.
Theinterarrivaltimesbetweenconsecutivejobsinsuchataskmay
varywidely.

Moreaboutaperiodicand
sporadictasks
Theinterarrivaltimesofaperiodicand
sporadicjobsmaybearbitrarilysmall.
Thejobsineachtaskmodeltheworkdoneby
thesysteminresponsetoeventsofthesame
type.
Thejobsineachaperiodictaskaresimilarin
thesensethattheyhavethesamestatistical
behaviourandthesametimingrequirement.

Aperiodictasks
Interarrivaltimesofaperiodicjobsareidenticallydistributed
randomvariableswithprobabilitydistributionA(x)
Similarlytheexecutiontimesofjobsineachaperiodicor
sporadictaskareidenticallydistributedrandomvariables
accordingtoprobabilitydistributionB(x)
Theseassumptionsmeanthatthestatisticalbehaviourofthe
systemdoesnotchangewithtime.i.e.thesystemis
stationary.

Moreaboutaperiodictasks
Thatthesystemisstationaryisusuallyvalidforatimeinterval
oflengthoforderH.
Thatisthesystemisstationaryduringanyhyperperiodduring
whichnoperiodictasksareaddedordeleted.
Wesayataskisaperiodicifthejobsinithaveeithersoft
deadlinesornodeadlines.
Wethereforewanttooptimizetheresponsivenessofthe
systemfortheaperiodicjobs,butneverattheexpenseofhard
realtimetaskswhosedeadlinesmustbemetatalltimes.

Whatisasporadictask?
Taskscontainingjobsthatarereleasedat
randomtimeinstantsandhaveharddeadlines
aresporadictasks.
Wetreatsporadictasksashardrealtimetasks.
Ourprimaryconcernistoensurethattheir
deadlinesaremet.
Minimizingtheirresponsetimesisof
secondaryimportance.

Examplesofaperiodicand
sporadictasks
Aperiodictask
Anoperatoradjuststhesensitivityofaradarsystem.The
radarmustcontinuetooperateandinthenearfuture
changeitssensitivity.

Sporadictask
Anautopilotisrequiredtorespondtoapilotscommand
todisengagetheautopilotandswitchtomanualcontrol
withinaspecifiedtime.
Similarlyafaulttolerantsystemmayberequiredtodetect
afaultandrecoverfromitintimetopreventdisaster.

Precedenceconstraints
Dataandcontroldependenciesamongjobs
mayconstraintheorderinwhichtheycan
execute
Suchjobsaresaidtohaveprecedence
constraints
Ifjobscanexecuteinanyorder,theyare
saidtobeindependent

Precedenceconstraintexample
Inaradarsurveillancesystemthesignalprocessingtaskisthe
producerortrackrecordswhichthetrackertaskisthe
consumer.
Eachtrackerjobprocessesthetrackrecordsproducedbya
signalprocessingjob.
Thetrackerjobisprecedenceconstrained.
Ingeneralaconsumerjobhasthisconstraintwheneverit
mustsynchronizewiththecorrespondingproducerjoband
waituntiltheproducercompletesinordertoexecute.

Precedenceconstraintsexample2
Consideraninformationserver.
Beforeaqueryisprocessedandtherequested
informationretrieved,itsauthorizationtoaccessthe
informationmustfirstbechecked.
Theretrievaljobcannotbeginexecutionbeforethe
authenticationjobcompletes.
Thecommunicationjobthatforwardsthe
informationtotherequestercannotbeginuntilthe
retrievaljobcompletes.

Precedencegraphandtaskgraph
Weuseapartialorderrelation<,calleda
precedencerelation,overthesetofjobsto
specifytheprecedenceconstraintsamong
jobs.
AjobJiisapredecessorofanotherjobjk(and
jkisasuccessorofji)ifjkcannotbegin
executionuntiltheexecutionofj icompletes.
Thisisrepresentedasji<jk

Precedencegraph(2)
Jiisanimmediatepredecessorofjk
(andjkisisanimmediatesuccessorofji)
ifji<jkandthereisnootherjobjjsuchthatji<jj<
jk
Twojobsjiandjkareindependentwhenneitherji<
jknorjk<ji
Ajobwithpredecessorsisreadyforexecutionwhen
thetimeisatorafteritsreleasetimeandallofits
predecessorsarecompleted.

Aprecedencegraph
Aprecedencegraphisadirectedgraph
whichrepresentstheprecedenceconstraints
amongasetofjobsJ.
EachvertexrepresentsajobinJ.
ThereisadirectededgefromvertexJito
vertexJkwhenthejobJiisanimmediate
predecessorofjobJk

Taskgraphs
Ataskgraph,whichgivesusageneralway
todescribeanapplicationsystem,isan
extendedprecedencegraph.
Asinaprecedencegraph,verticesrepresent
jobs.Theyareshownascirclesandsquares
(thedistinctionbetweenthemwillcome
later).

Taskgraph(2)
Thenumbersinthebracketaboveeachjob
givesusitsfeasibleinterval.
Theedgesinthegraphrepresent
dependenciesamongjobs.
Ifalltheedgesareprecedenceedges
representingprecedenceconstraintsthenthe
graphisaprecedencegraph.

Exampleoftaskgraphs

Taskgraphexamples
Thesystemshowninthesampletaskgraphincludestwo
periodictasks.
Thetaskwhosejobsarerepresentedbytheverticesinthe
toprowhasaphase0,period2,andrelativedeadline7.
Thejobsinitareindependentsincetherearenoedgesto
orfromthesejobs.
Inotherwords,thejobsreleasedinlaterperiodsareready
forexecutionassoonastheyarereleased,eventhough
somejobreleasedearlierisnotyetcomplete.
Thisiscommonwithperiodictasks.

Taskgraphexamples(2)
Theverticesinthesecondrowrepresentjobsinaperiodictaskwith
phase2,
period3,andrelativedeadline3.
Thejobsinitaredependent.
Thefirstjobistheimmediatepredecessorofthesecondjob,the
secondjobistheimmediatepredecessorofthethirdjob,etc.
Theprecedencegraphofthejobsinthistaskisachain.
AsubgraphsbeingachainindicatesthatforeverypairofjobsJiand
Jkinthesubgraph,eitherJi<JkorJk<Ji
Hencethejobsmustbeexecutedinserialorder.

Otherkindsoftaskgraphs
Ataskgraphliketheexampleisonlyreallynecessarywhen
thesystemcontainscomponentswhichhavecomplex
dependencieslikethesubgraphbelowtheperiodictasks.
Manytypesofinteractionsandcommunicationamongjobs
arenotcapturedbyaprecedencegraphbutcanbecaptured
byataskgraph.
Unlikeaprecedencegraph,ataskgraphcancontain
differencetypesofedgesrepresentingdifferenttypesof
dependencies.

DataDependency
Datadependencycannotbecapturedbyaprecedencegraph.
Inmanyrealtimesystemsjobscommunicateviashareddata.
Oftenthedesignerchoosesnottosynchronizeproducerand
consumerjobs.Insteadtheproducerplacesthedataina
sharedaddressspacetobeusedbytheconsumeratanytime.
Inthiscasetheprecedencegraphwillshowtheproducerand
consumerjobsasindependentsincetheyareapparentlynot
constrainedtoruninturn.

Datadependency2
Inataskgraph,datadependenciesarerepresentedexplicitlybydata
dependencyedgesamongjobs.
ThereisadatadependencyedgefromthevertexJitovertexJkinthe
taskgraphifthejobJkconsumesdatageneratedbyJiorthejobJi
sendsmessagestoJk
AparameterofanedgefromJitoJkisthevolumeofdatafromJitoJk.
Inmultipleprocessorsystemsthevolumeofdatatobetransferredcan
beusedtomakedecisionsaboutschedulingofjobsonprocessors.

Datadependency3
Sometimestheschedulermaynotbeabletoscheduledatadependent
jobsindependently.
Toensuredataintegritysomelockingmechanismmustbeusedto
ensurethatonlyonejobcanaccesstheshareddataatatime.
Thisleadstoresourcecontention,whichmayalsoconstraintheway
jobsexecute.
Howeverthisconstraintisimposedbyschedulingandresourcecontrol
algorithms.
Itisnotaprecedenceconstraintbecauseitisnotanintrinsicconstraint
ontheexecutionorderofjobs.

Functionalparameters
Whileschedulingandresourcecontroldecisionsaremade
independentlyofmostfunctionalcharacteristicsofjobs,there
areseveralfunctionalpropertiesthatdoaffectthesedecisions.
Theworkloadmodelmustexplicitlydescribetheseproperties
usingfunctionalparameters:

Preemptivity
Criticality
Optionalinterval
Laxitytype

PreemptivityofJobs
Executionofjobscanoftenbeinterleaved.The
schedulermaysuspendtheexecutionofalessurgent
jobandgivetheprocessortoamoreurgentjob.Later,
thelessurgentjobcanresumeitsexecution.
Thisinterruptionofjobexecutioniscalledpreemption.
Ajobispreemptableifitsexecutioncanbesuspended
atanytimetoallowtheexecutionofotherjobsandcan
laterberesumedfromthepointofsuspension.

PreemptivityofJobs2
Ajobisnonpreemptableifitmustbeexecutedfromstartto
completionwithoutinterruption.
Thisconstraintmaybeimposedbecauseitsexecution,ifsuspended,
mustbeexecutedagainfromthebeginning.
Sometimesajobmaybepreemptableeverywhereexceptforasmall
portionwhichisconstrainedtobenonpreemptable.
Anexampleisaninterrupthandlingjob.Aninterrupthandlingjob
usuallybeginsbysavingthestateoftheprocessor.Thissmall
portionofthejobisnonpreemptablesincesuspendingtheexecution
maycauseseriouserrorsinthedatastructuressharedbythejobs.

PreemptivityofJobs3
Duringpreemptionthesystemmustfirstsavethestateofthepreempted
jobatthetimeofpreemptionsothatitcanresumethejobfromthatstate.
Thenthesystemmustpreparetheexecutionenvironmentforthe
preemptingjobbeforestartingthejob.
e.g.inthecaseofCPUjobs,thestateofthepreemptedjobincludesthe
contentsoftheCPUregisters.Aftersavingthecontentsoftheregisters
inmemoryandbeforethepreemptingjobcanstart,theoperatingsystem
mustloadthenewregistervalues,clearpipelines,perhapsclearthe
caches,etc.
Theseactionsarecalledacontextswitch.

PreemptivityofJobs4
Theamountoftimerequiredtoaccomplishacontextswitchis
calledacontextswitchtime.
Thetermscontextswitchandcontextswitchtimeareusedto
meantheoverheadworkdoneduringpreemption,andthetime
requiredtoaccomplishthiswork.
Thefactthatajobisnonpreemptableistreatedasaconstraint
ofthejob.
Thenonpreemptabilityofajobmaybeaconsequenceofa
constraintontheusageofsomeresource.

CriticalityofJobs
Inanysystem,jobsarenotequallyimportant.
Theimportance(orcriticality)ofajobisapositivenumber
thatindicateshowcriticalajobiswithrespecttootherjobs.
Somebooksusethetermspriorityandweighttoreferto
importance
Themoreimportantajob,thehigheritspriorityorthelargerits
weight

Becausepriorityandweightcanhaveothermeanings,wewill
usethetermsimportanceorcriticalitytomeasurecriticality.

CriticalityofJobs2
Duringanoverloadwhenitisnotpossibleto
scheduleallthejobstomeettheirdeadlines,it
maymakesensetosacrificethelesscritical
jobs,sothatthemorecriticaljobsmeettheir
deadlines.
Forthisreason,someschedulingalgorithmstry
tooptimizeweightedperformancemeasures,
takingintoaccounttheimportanceofjobs.

Resourceparametersofjobsand
parametersofresources
Everyjobrequiresaprocessorthroughoutits
execution.
Ajobmayalsorequiresomeresources.
Theresourceparametersofeachjobgiveusthetype
ofprocessorandtheunitsofeachresourcetype
requiredbythejobandthetimeintervalsduringits
executionwhentheresourcesarerequired.
Theseparametersareneededtosupportresource
managementdecisions.

Preemptivityofresources
Theresourceparametersofjobsgiveusapartialviewofthe
processorsandresourcesfromtheperspectiveofthe
applications.
Sometimesweneedtodescribethecharacteristicsof
processorsandresourcesindependentoftheapplication.
Forthisweuseparametersofresources.
Aresourceparameterispreemptivity.
Aresourceisnonpreemptableifeachunitoftheresourceis
constrainedtobeusedserially.

Preemptivityofresources2
Onceaunitofanonpreemptableresourceisallocatedtoajob,other
jobsneedingtheunitmustwaituntilthejobcompletesitsuse.
Ifjobscanuseeveryunitofaresourceinaninterleavedway,the
resourceispreemptable.
Alockonadataobjectisanexampleofanonpreemptableresource.
Thisdoesnotmeanthatthejobisnonpreemptableonothers
resourcesorontheprocessor.
Thetransactioncanbepreemptedontheprocessorbyother
transactionsnotwaitingforthelocks.

ResourceGraph

Aresourcegraphdescribestheconfigurationofresources.
ThereisavertexRiforeveryprocessororresourceRiinthe
system.
Wecantreatresourcesandprocessorssimilarlyforthesakeof
convenience.
Theattributesofthevertexaretheparametersoftheresource.
Theresourcetypeofaresourcetellsuswhethertheresourceis
aprocessororapassiveresource,anditsnumbergivesusthe
numberofavailableunits.

Resourcegraph2
Edgesinresourcegraphsrepresentthe
relationshipamongresources.
Usingdifferenttypesofedgeswecan
describedifferentconfigurationsofthe
underlyingsystem.

Resourcegraph3
Thereare2typesofedgesinresourcegraphs
AnedgefromvertexRitovertexRkcanmeanthatRkisacomponent
ofRi.e.g.amemoryispartofacomputerandsoisamonitor.
Thisedgeisanisapartofedge.
Thesubgraphcontainingalltheisapartofedgesisaforest.The
rootofeachtreerepresentsamajorcomponent,withsubcomponents
representedbyvertices.e.g.theresourcegraphofasystem
containing2computersconsistsof2trees.Therootofeachtree
representsacomputerwithchildrenofthisvertexincludingCPUsetc.

Resourcegraph4
Theothertypeofedgeinresourcegraphs
Someedgesinresourcegraphsrepresentconnectivitybetweencomponents.
Theseedgesarecalledaccessibilityedges.
e.g.ifthereisaconnectionbetweentwoCPUsinthetwocomputers,theneach
CPUisaccessiblefromtheothercomputerandthereisanaccessibilityedge
fromeachcomputertotheCPUoftheothercomputer.
Eachaccessibilityedgemayhaveseveralparameters.
e.g.aparameterofanaccessibilityedgefromaprocessorPitoanotherPkisthe
costofsendingaunitofdatafromajobexecutingonPitoajobexecutingonPk
Somealgorithmsusesuchinformationtodecidehowtoallocatejobsand
resourcestoprocessorsinastaticallyconfiguredsystem.

Schedulinghierarchy
Thefiguremodelofarealtimesystemshowsthethree
elementsofourmodelofrealtimesystems.
Theapplicationsystemisrepresentedby
ataskgraphwhichgivestheprocessortimeandresource
requirementsofjobs,theirtimingconstraintsanddependencies
Aresourcegraphdescribingtheresourcesavailabletoexecutethe
applicationsystem,theirattributesandrulesgoverningtheiruse
Andbetweenthesegraphsaretheschedulingandresource
accesscontrolalgorithmsusedbytheoperatingsystem.

Modelofarealtimesystem

Schedulerandschedules
Jobsarescheduledandallocatedresources
accordingtoachosensetofscheduling
algorithmsandresourceaccesscontrol
protocols.
Theschedulerisamodulethatimplements
thesealgorithms.
Theschedulerassignsprocessorstojobs,or
equivalently,assignsjobstoprocessors.

Schedulerandschedules2
Ajobisscheduledinatimeintervalonaprocessorifthe
processorisassignedtothejob,andhencethejobexecutes
ontheprocessor,inthetimeinterval.
Thetotalamountofprocessortimeassignedtoajob
accordingtoascheduleisthetotallengthofallthetime
intervalsduringwhichthejobisscheduledonsome
processor.
Ascheduleisanassignmentbytheschedulerofallthejobs
inthesystemontheavailableprocessors.

Schedulerandschedules3

Aschedulerworkscorrectlyifitproducesonlyvalidschedules.
Avalidschedulesatisifiesthefollowingconditions:

1.Everyprocessorisassignedtoatmostonejobatanytime.
2.Everyjobisassignedatmostoneprocessoratanytime.
3.Nojobisscheduledbeforeitsreleasetime.
4.Dependingontheschedulingalgorithmsused,thetotalamountof
processortimeassignedtoeveryjobisequaltoitsmaximumoractual
executiontime.
5.Alltheprecedenceandresourceusageconstraintsaresatisfied.

Schedulerandschedules4
Notethatwehaveassumedimplicitlythatjobsdo
notruninparallelonmorethanoneprocessorto
speeduptheirexecution.
Ofcourseitmaybepossibletorunparalleljobsbut
wewillnotbeconsideringsuchacomplicationat
thisstage.

Feasibility
Avalidscheduleisafeasiblescheduleif
everyjobcompletesbyitsdeadlineandin
generalmeetsitstimingconstraints.
Asetofjobsisschedulableaccordingtoa
schedulingalgorithmifwhenusingthe
algorithmthescheduleralwaysproducesa
feasibleschedule.

Optimality
Thecriterionweusuallyusetotomeasuretheperformanceof
schedulingalgorithmsisforhardrealtimeapplicationsistheir
abilitytofindfeasibleschedulesofthegivenapplicationsystem
wheneversuchschedulesexist.
Ahardrealtimeschedulingalgorithmisoptimalifusingthe
algorithmthescheduleralwaysproducesafeasiblescheduleifthe
givensetofjobshasfeasibleschedules.
Ifanoptimalalgorithmcannotfindafeasibleschedule,wecan
concludethatagivensetofjobscannotfeasiblybescheduledby
anyalgorithm.

Otherschedulingperformance
measures
Apartfromfeasibilityothercommonlyused
performancemeasuresinclude:

Maximumandaveragetardiness
Lateness
Responsetime
Miss,lossandinvalidrates

Therightchoiceofperformancemeasure
dependsontheobjectiveofscheduling.

Otherschedulingperformance
measures2
e.g.whenasetofjobsisnotschedulablebyany
algorithm,wemaysettleforascheduleaccordingto
whichthenumberofjobsfailingtocompleteintimeis
smallest.
Henceanalgorithmperformsbetterifitcanproducea
schedulewithasmallernumberoflatejobsthanothers.
Alternativelywemaybemoreconcernedabout
tardiness,i.e.howlatethingscanbe,ratherthanhow
manyjobsarelate.

Otherschedulingperformance
measures3
Thelatenessofajobisthedifferencebetweenits
completiontimeanditsdeadline.
Unlikethetardinessofajob,whichisnevernegative,
latenessofajobwhichcompletesbeforeitsdeadlineis
negative.Latenessispositiveifthejobcompletesafterits
deadline.
Sometimeswewishtokeepjittersincompletiontimes
small.Wecandothisbyusingschedulingalgorithmsthat
trytominimizetheaverageabsolutelatenessofjobs.

Otherschedulingperformance
measures4
Whenalljobshavethesamereleasetimeand
deadline,theproblemofschedulingthejobstomeet
theirdeadlinesisthesameasthatofschedulingto
minimizethecompletiontimeofthejobwhich
completeslast.
Theresponsetimeofthatjobistheresponsetimeof
thesetofjobsasawhole,andisoftencalledthe
makespanoftheschedule.

Otherschedulingperformance
measures5
Themakespanisaperformancecriterioncommonly
usedtocompareschedulingalgorithms.
Analgorithmthatproducesaschedulewitha
shortermakespanisbetter.
Ifthemakespanislessthanorequaltothelengthof
theirfeasibleinterval,thejobscanmeettheir
deadline.

Otherschedulingperformance
measures6
Themostfrequentlyusedperformancemeasurefor
jobswithsoftdeadlinesistheiraverageresponsetime.
Wecancomparetheperformanceofscheduling
algorithmsonagivensetofjobsbasedontheaverage
responsetimesofthejobswhenscheduledaccording
tothealgorithms.
Thesmallertheaverageresponsetime,thebetterthe
algorithm.

Otherschedulingperformance
measures7
Inasystemwithamixtureofjobswithhardandsoft
deadlines,theobjectiveofschedulingistypicallyto
minimizetheresponsetimeofjobswithsoftdeadlines
whileensuringthatalljobswithharddeadlinescomplete
intime.
Sincethereisnoadvantageincompletingjobswithhard
deadlinesearly,wemaydelaytheirexecutioninorderto
improvetheresponsetimeofjobswithsoftdeadlines.

Otherschedulingperformance
measures8
Formanysoftrealtimeapplicationsitisacceptableto
completesomejobslateortodiscardlatejobs.
Forsuchapplicationssuitableperformancemeasures
includesthemissrateandlossrate.
Missrategivesthepercentageofjobsthatareexecuted
butcompletelate.
Lossrategivesthepercentageofjobsthatarenot
executedatall.

Otherschedulingperformance
measures9
Whenitisimpossibletocompletealljobsontime,ascheduler
maychoosetodiscardsomejobs.
Bydiscardingsomejobstheschedulerincreasesthelossrate
butcompletesmorejobsintime.Thusitreducesthemissrate.
Similarly,reducingthelossratemayleadtoanincreasein
missrate.
Thuswhenwetalkaboutminimizingthemissrate,wemean
thatthemissrateisreducedasmuchaspossiblesubjectto
keepingthelossratebelowsomeacceptablethreshold.

Otherschedulingperformance
measures10
Alternativelywemaywanttominimizethelossrate
providedthemissrateisbelowsomethreshold.
Aperformancemeasurethatcapturesthistradeoffis
theinvalidrate.
Theinvalidrateisthesumofthemissandlossrates,
andgivesthepercentageofjobsthatdonotproducea
usefulresult.
Wetrytominimizetheinvalidrate.

InteractionamongSchedulers

Sofarwehaveconsideredschedulingtheapplicationsystemon
theunderlyingresourcesandprocessors.
Typicallyasystemhasahierarchyofschedulers.
Someprocessorsandresourcesusedbytheapplicationsystemare
notphysicalentities,rathertheyarelogicalresources.
Logicalresourcesmustbescheduledonphysicalresources.
Thealgorithmsusedforthisschedulingaredifferentfromthose
usedtoscheduletheapplicationsystemusingtheresource.

InteractionamongSchedulers2
Ajobmaymodelaserverthatexecutesonbehalfof
itsclientjobs.
Thetimeandresourcesallocatedtotheserverjob
mustinturnbeallocatedtoitsclientjobs.
Againthealgorithmusedbytheservertoscheduleits
clientsmaybedifferentfromthealgorithmusedby
theoperatingsystemtoscheduletheserverwithother
servers.

InteractionamongSchedulers3
Considerasanexampledatabaselocksasresources.
Infacttheseresourcesareimplementedbyadatabasemanagement
systemwhoseexecutionisscheduledononeormoreprocessors.
Theschedulerthatschedulesthedatabasemanagementsystemmay
bedifferentfromtheschedulerthatschedulestheapplicationsystem
usingthelocks,andmayusedifferentalgorithms.
Thuswehavetwolevelsofscheduling.
Inthehigherleveltheapplicationsystemisscheduledontheresources.
Inthelowerlevel,thejobsimplementingtheresourcesarescheduledonthe
processorsandresourcesneededbythem.

InteractionamongSchedulers4
Consideranotherexampleofanapplicationsystemcontainingperiodictasksand
aperiodicjobsononeprocessor.
Alltheaperiodicjobsareplacedinaqueuewhentheyarereleased.
Thereisapoller.
Togetherwiththeperiodictasks,thepollerisscheduledtoexecuteperiodically.
Whenthepollerexecutes,itcheckstheaperiodicjobqueue.
Ifthereareaperiodicjobswaiting,itchoosesanaperiodicjobfromthequeueand
executesthejob.Hencetheaperiodicjobsareclientsofthepoller.
Weagainhavetwolevelsofscheduling
Inthelowerlevel,theschedulerprovidedbytheoperatingsystemschedulesthepollerandother
periodictasks
Inthehigherlevelthepollerschedulesitsclients.

InteractionamongSchedulers5
Ineveryleveloftheschedulinghierarchywecan
representtheworkloadbyataskgraphandthe
processorsandresourcesrequiredbyitwitha
resourcegraph.
Thuseverylevelintheschedulinghierarchycanbe
representedinauniformway.

CommonlyUsedApproachesto
RealTimeScheduling
Wewillexaminethreecommonlyusedapproaches
torealtimescheduling
Clockdriven
Weightedroundrobin
Prioritydriven

Theweightedroundrobinapproachismainlyused
forschedulingrealtimetrafficinhighspeed
switchednetworks.Itisnotidealforscheduling
jobsonCPUs.

ClockDrivenApproach
Clockdrivenschedulingisoftencalledtimedrivenscheduling.
Whenschedulingisclockdriven,decisionsaremadeatspecifictime
instantsonwhatjobsshouldexecutewhen.
Typicallyinasystemusingclockdrivenscheduling,alltheparametersof
hardrealtimejobsarefixedandknown.
Ascheduleofthejobsiscomputedofflineandisstoredforuseatrun
time.
Theschedulerschedulesthejobsaccordingtothisscheduleateach
schedulingdecisiontime.

Thusschedulingoverheadatruntimeisminimized.

Clockdrivenapproach2
Schedulingdecisionsareusuallymadeatregularlyspacedtime
instants.
Onewaytoimplementthisistouseahardwaretimersettoexpire
periodicallywhichcausesaninterruptwhichinvokesthe
scheduler.
Whenthesystemisinitialized,theschedulerselectsandschedules
thejobsthatwillexecuteuntilthenextschedulingdecisiontime
andthenblocksitselfwaitingfortheexpirationofthetimer.
Whenthetimerexpires,theschedulerrepeatstheseactions.

Roundrobinapproach

Theroundrobinapproachiscommonlyusedforschedulingtime
sharedapplications.
Whenjobsarescheduledinaroundrobinsystem,everyjobjoinsa
firstinfirstout(FIFO)queuewhenitbecomesreadyforexecution.
Thejobattheheadofthequeueexecutesforatmostonetimeslice.
Ifthejobdoesnotcompletebytheendofthetimeslice,itis
preemptedandplacedattheendofthequeuetowaitforitsnextturn.
Whentherearenreadyjobsinthequeue,eachjobgetsonetimeslice
inn,thatiseveryround.

Roundrobinapproach2
Becausethelengthofthetimesliceisrelativelyshort
(typicallytensofmilliseconds)theexecutionofeach
jobsbeginsalmostimmediatelyafteritbecomes
ready.
Inessence,eachjobgets1/nthshareoftheprocessor
whentherearenjobsreadyforexecution.
Thisiswhytheroundrobinalgorithmisalsoknown
astheprocessorsharingalgorithm.

Weightedroundrobinapproach

Theweightedroundrobinalgorithmhasbeenusedforschedulingreal
timetrafficinhighspeedswitchednetworks.
Ratherthangivingallthereadyjobsequalsharesoftheprocessor,
differentjobsmaybegivendifferentweights.
Theweightsrefertothefractionoftheprocessortimeallocatedtothejob.
Ajobwithweightwtgetswttimesliceseveryround.
Thelengthoftheroundequalsthesumoftheweightsofallthereadyjobs.
Byadjustingtheweightsofjobswecanspeeduporslowdownthe
progressofeachjob.

Weightedroundrobinapproach
2
Bygivingeachjobafractionoftheprocessor,aroundrobin

schedulerdelaysthecompletionofeveryjob.
Ifroundrobinschedulingisusedtoscheduleprecedenceconstrained
jobs,theresponsetimeofachainofjobscangetverylarge.
Forthisreason,theweightedroundrobinapproachisunsuitablefor
schedulingsuchjobs.
Howeverifasuccessorjobisabletoconsumeincrementallywhatis
producedbyapredecessorjob,suchaswithaUnixpipe,weighted
roundrobinschedulingmaybeareasonableapproach.

Weightedroundrobinapproach
3
Forexampleconsidertwosetsofjobs
J1={J1,1,J1,2}andJ2={J2,1,J2,2}
Thereleasetimesofalljobsare0
Theexecutiontimesofalljobsare1
J1,1andJ2,1executeonprocessorP1
J1,2andJ2,2executeonprocessorP2
SupposethatJ1,1isthepredecessorofJ1,2
SupposethatJ2,1isthepredecessorofJ2,2

RoundRobinScheduling

Weightedroundrobinapproach
4
Wecanseeinthefigureroundrobinschedulingthatbothsetsofjobs
completeapproximatelyattime4ifthejobsarescheduledinaweighted
roundrobinmanner.
Incontrast,wecanseethatifthejobsoneachprocessorarescheduled
oneaftertheother,oneofthechainscancompleteattime2andtheother
attime3.
Supposethattheresultofthefirstjobineachsetispipedtothesecond
jobintheset.Thelattercanexecuteaftereachoneorafewtimeslices
oftheformercomplete.
Thenitisbettertoschedulethejobsonaroundrobinbasis,becauseboth
setscancompleteafewtimeslicesaftertime2.

Weightedroundrobinapproach
5
Inaswitchednetworkadownstreamswitchcanbeginto
transmitanearlierportionofthemessageassoonasitreceives
theportion.
Itdoesnothavetowaitforthearrivaloftherestofthemessage.
Theweightedroundrobinapproachdoesnotrequireasorted
priorityqueue,onlyaroundrobinqueue.
Thisisadistinctadvantageforschedulingmessage
transmissionsinultrahighspeednetworkssincefastpriority
queuesareveryexpensive.

Prioritydrivenapproach
Thetermprioritydrivenalgorithmsreferstoaclassofscheduling
algorithmsthatneverleaveanyresourceidleintentionally.
Withaprioritydrivenalgorithmaresourceidlesonlywhenno
jobrequiringtheresourceisreadyforexecution.
Schedulingdecisionsaremadewheneventssuchasreleasesand
completionsofjobsoccur.
Prioritydrivenalgorithmsareeventdriven.
Othercommonlyusedtermsforthisapproacharegreedy
scheduling,listscheduling,andworkconservingscheduling.

Prioritydrivenapproach2
Aprioritydrivenalgorithmisgreedybecauseittriestomake
locallyoptimaldecisions.
Leavingaresourceidlewhilesomejobisreadytousetheresource
isnotlocallyoptimal.
Whenaprocessororresourceisavailableandsomejobcanuseit
tomakeprogress,aprioritydrivenalgorithmnevermakesthejob
wait.
Howevertherearecaseswhereitisbettertohavesomejobswait
evenwhentheyarereadytoexecuteandtheresourcestheyrequire
areavailable.

Prioritydrivenapproach3
Thetermlistschedulingisalsousedbecauseanyprioritydriven
algorithmcanbeimplementedbyassigningprioritiestojobs.
Jobsreadyforexecutionareplacedinoneormorequeuesordered
bytheprioritiesofthejobs.
Atanyschedulingdecisiontime,thejobswiththehighestpriorities
arescheduledandexecutedontheavailableprocessors.
Henceaprioritydrivenschedulingalgorithmisdefinedlargelyby
thelistofprioritiesitassignstojobs.
Theprioritylistandotherrulessuchaswhetherpreemptionis
allowed,definetheschedulingalgorithmcompletely.

Prioritydrivenapproach4
Mostnonrealtimeschedulingalgorithmsareprioritydriven.
Examplesinclude:
FIFO(firstinfirstout)andLIFO(lastinfirstout)algorithmswhichassign
prioritiestojobsbasedontheirreleasetimes.
SETF(shortestexecutiontimefirst)andLETF(longestexecutiontimefirst)
algorithmswhichassignprioritiesbasedonjobexecutiontimes.

Becausewecandynamicallychangetheprioritiesofjobs,evenround
robinschedulingcanbethoughtofasprioritydriven.
Thepriorityoftheexecutingjobisloweredtotheminimumamongall
jobswaitingforexecutionafterthejobhasexecutedforatimeslice.

Prioritydrivenapproach5
Thefigureexamplesofprioritydrivenscheduling

Prioritydrivenapproach6
Inthefigureexamplesofprioritydrivenscheduling
Thetaskgraphisaprecedencegraphwithalledgesshowingprecedence
constraints.
Thenumbernexttothenameofeachjobisitsexecutiontime.
J5isreleasedattime4.
Alltheotherjobsarereleasedattime0.
WewanttoscheduleandexecutethejobsontwoprocessorsP1andP2.
Theycommunicateviaasharedmemoryhencecommunicationcostsare
negligible.
Theschedulersoftheprocessorsshareacommonpriorityqueueofreadyjobs.

Prioritydrivenapproach7

Theprioritylistisgivennexttothegraph.
JihasahigherprioritythanJkifi<k.

Allthejobsarepreemptable
Schedulingdecisionsaremadewheneversomejobbecomesreadyfor
executionorsomejobcompletes.
Thefirstschedule(a)showsthescheduleofjobsonthetwoprocessors
generatedbytheprioritydrivenalgorithmfollowingthispriorityassignment.
Attime0,jobsJ1,J2,andJ7arereadyforexecution.
Theyaretheonlyjobsinthepriorityqueueatthistime.
SinceJ1andJ2havehigherprioritiesthanJ7theyareaheadofJ7inthequeue
andhencearescheduled.

Prioritydrivenapproach8

Attime1,J2completesandhenceJ3becomesready.J3isplacedinthe
priorityqueueaheadofJ7andisscheduledonP2,theprocessorfreedbyJ2.
Attime3,bothJ1andJ3complete.J5isstillnotreleased.J4andJ7are
scheduled.
Attime4,J5isreleased.Nowtherearethreereadyjobs.J7hasthelowest
priorityamongthemsoitispreemptedandJ4andJ5havetheprocessors.
Attime5,J4completes.J7resumesonprocessorP1.
Attime6,J5completes.BecauseJ7isnotyetcompleted,bothJ6andJ8are
notyetreadyforexecution.ThusprocessorP2becomesidle.
J7finallycompletesattime8.J6andJ8cannowbescheduledonthe
processors.

Prioritydrivenapproach9
Thelowerschedule(b)showsanonpreemptivescheduleaccording
tothesamepriorityassignment.
Beforetime4thisscheduleisthesameasbefore.
Howeverattime4whenJ5isreleased,bothprocessorsarebusy.J5
hastowaituntilJ4completesattime5beforeitcanbegin
execution.
Itturnsoutthatforthissystem,postponementofthehigherpriority
jobbenefitsthesetofjobsasawhole.
Theentiresetcompletesonetimeunitearlieraccordingtothenon
preemptiveschedule.

Prioritydrivenapproach10
Ingeneralhowever,nonpreemptiveschedulingisnotbetterthan
preemptivescheduling.
Thequestioniswhenispreemptiveschedulingbetterthannonpreemptive
schedulingandviceversa?
Thereisnoknownanswertothisquestioningeneral.
Inthespecialcasewherejobshavethesamereleasetime,preemptive
schedulingisbetter,whenthecostofpreemptionisignored.
Specifically,inamultiprocessorsystem,theminimummakespan(i.e.the
responsetimeofthejobthatcompleteslastamongallthejobs)achievable
byanoptimalpreemptivealgorithmisshorterthanthemakespan
achievablebyanoptimalnonpreemptivealgorithm.

Prioritydrivenapproach11
Thequestionhereiswhetherthedifferenceintheminimum
makespansachievablebythetowclassesofalgorithmsissignificant.
Inparticularisthetheoreticalgaininmakespanachievableby
preemptionenoughtocompensateforthecontextswitchoverheadof
preemption?
Theanswertothisquestionisonlyknownforthetwoprocessorcase,
whereithasbeenshownthattheminimummakespanachievableby
nonpreemptivealgorithmsisnevermorethan4/3timestheminimum
makespanachievablebypreemptivealgorithmswhenthecostof
preemptionisnegligible.

DynamicversusStaticSystems
Wehaveseenexamplesofjobsthatarereadyforexecutionbeing
placedinapriorityqueuecommontoallprocessors.
Whenaprocessorisavailable,thejobattheheadofthequeue
executesontheprocessor.
Suchasystemiscalledadynamicsystem,becausejobsare
dynamicallydispatchedtoprocessors.
Intheexampleofpriorityschedulingweallowedeachpreempted
jobtoresumeonanyprocessor.
Wesayajobmigratesifitstartsexecutiononaprocessor,is
preempted,andlaterresumesonadifferentprocessor.

DynamicversusStaticSystems2
Analternateapproachtoschedulinginmultiprocessoranddistributed
systemsistopartitionthejobsinthesystemintosubsystemsandto
allocatethesubsystemsstaticallytoparticularprocessors.
Insuchsystems,jobsaremovedbetweenprocessorsonlywhenthe
systemmustbereconfiguredsuchaswhenaprocessorfails.
Wecallsuchsystems,staticsystems,becausethesystemisstatically
configured.
Ifjobsondifferentprocessorsaredependenttheschedulersonthe
processorsmustsynchronizethejobsaccordingtosomesynchronization
andresourceaccesscontrolprotocol.
Otherwise,jobsoneachprocessorarescheduledbythemselves

DynamicversusStaticSystems3
Forexamplewecoulddoastaticpartitioningofthejobsinour
prioritydrivenschedulingexample.
PutJ1,J2,J3,J4onP1andtheremainingjobsonP2.
Theprioritylistissegmentedintotwoparts:
(J1,J2,J3,J4)usedbytheschedulerofprocessorP1
(J5,J6,J7,J8)usedbytheschedulerofprocessorP2

ItiseasytoseethatthejobsonP1completebytime8andthejobson
P2completebytime11.
AlsoJ2completesbytime4whileJ6startsattime6,thusthe
precedenceconstraintissatisfied.

DynamicversusStaticSystems4
Inthisexampletheresponseofthestaticsystemisjustasgoodasthatof
thedynamicsystem.
Ingeneralwemayexpectthatwecangetbetteraverageresponseby
dynamicallydispatchingandexecutingjobs.
Whiledynamicsystemsmaybemoreresponsiveonaverage,theirworst
caserealtimeperformancemaybepoorerthanstaticsystems.
Moreimportantly,thereexistnoreliabletechniquesforvalidatingthe
timingcharacteristicsofdynamicsystems,whereassuchtechniquesexist
forstaticsystems.
Forthisreason,mosthardrealtimesystemsimplementedtodayarestatic.

Effectivereleasetimesanddeadlines
Thegivenreleasetimesanddeadlinesaresometimes
inconsistentwiththeprecedenceconstraintsofthejobs.
i.e.thereleasetimeofajobmaybelaterthanthatofitssuccessors,
anditsdeadlinemaybeearlierthanthatofitspredecessors.

Ratherthanworkingwiththegivenreleasetimesanddeadlines,
wefirstderiveasetofeffectivereleasetimesanddeadlines
fromthesetimingconstraintstogetherwiththegiven
precedenceconstraints.
Thesederivedtimingconstraintsareconsistentwiththe
precedenceconstraints.

Effectivereleasetimesanddeadlines2

Wherethereisonlyoneprocessorwecancomputethederivedvalues:
EffectiveReleaseTime:

Theeffectivereleasetimeofajobwithoutpredecessorsisequaltoitsgivenreleasetime.
Theeffectivereleasetimeofajobwithpredecessorsisequaltothemaximumvalueamong
itsgivenreleasetimeandtheeffectivereleasetimesofallitspredecessors.

EffectiveDeadline:
Theeffectivedeadlineofajobwithoutasuccessorisequaltoitsgivendeadline.
Theeffectivedeadlineofajobwithsuccessorsisequaltotheminimumvalueamongits
givendeadlineandtheeffectivedeadlinesofallofitssuccessors.

Theeffectivereleasetimesofallthejobscanbecomputedinonepassthroughthe
precedencegraphinO(n2)timewherenisthenumberofjobs.Similarlyforthe
effectivedeadlines.

Effectivereleasetimesanddeadlines3
Considerthefollowingexamplewhosetaskgraphisgiven
inthefollowingfigureexampleofeffectivetiming
constraints

Effectivereleasetimesanddeadlines4
Considerthefollowingexamplewhosetaskgraphisgiveninfigure
exampleofeffectivetimingconstraints
Thenumbersinbracketsnexttoeachjobareitsgivenreleasetime
anddeadline.
BecauseJ1andJ2havenopredecessors,theireffectivereleasetimes
aretheirgivenreleasetimes,2and0respectively.
ThegivenreleasetimeofJ3is1,butthelatesteffectivereleasetime
ofitspredecessorsis2(thatofJ1)soitseffectivereleasetimeis2.
TheeffectivereleasetimesofJ4,J5,J6,J7are4,2,4,6respectively.

Effectivereleasetimesanddeadlines5
Considerthefollowingexamplewhosetaskgraphisgiveninfigure
exampleofeffectivetimingconstraints
J6andJ7havenosuccessorssotheireffectivedeadlinesaretheirgiven
deadlines,20and21respectively.
SincetheeffectivedeadlinesofthesuccessorsofJ4andJ5arelater
thanthegivendeadlinesofJ4andJ5,theeffectivedeadlinesofJ4and
J5areequaltotheirgivendeadlines,9and8respectively.
HoweverthegivendeadlineofJ3(12)islargerthantheminimum
value(8)ofitssuccessors,sotheeffectivedeadlineofJ3is8.
SimilarlytheeffectivedeadlinesofJ1andJ2are8and7respectively.

Effectivereleasetimesanddeadlines6
Notethatwehaveignoredtheexecutiontimesofjobsinworkingoutour
effectivereleasetimesanddeadlines.
Sotobeaccuratetheeffectivedeadlineofajobshouldbeasearlyasthe
deadlineofeachofitssuccessorsminustheexecutiontimeofthe
successor.
Theeffectivereleasetimeofthejobshouldbethatofitspredecessorplus
theexecutiontimeofthepredecessor.
Interestingly,whenthereisonlyoneprocessor,ithasbeenshownthatitis
feasibletoscheduleasetofjobsonaprocessoraccordingtotheirgiven
releasetimesanddeadlinesifandonlyifitisfeasibletoscheduletheset
accordingtotheireffectivereleasetimesanddeadlinesdefinedabove.

Effectivereleasetimesanddeadlines7
Whenthereisonlyoneprocessorandthejobsarepreemptable,working
withtheeffectivereleasetimesanddeadlinesallowsustotemporarily
ignoretheprecedenceconstraintsandtreatallthejobsasiftheyare
independent.
Ofcoursethatmeansthatwecouldproduceaninvalidschedulethatdoes
notmeetsomeprecedenceconstraint.
Inourlastexample,J1andJ3havethesameeffectivereleasetimeand
deadline.Analgorithmthatignorestheprecedenceconstraintbetween
themmayscheduleJ3beforeJ1.
Ifthathappens,wecanalwaysaddasteptoswapthetwojobs,andmake
thescheduleavalidone.

EarliestDeadlineFirst(EDF)
Algorithm
Awaytoassignprioritiestojobsisonthebasisoftheir
deadlines.
EarliestDeadlineFirst(EDF)algorithmisbasedonthe
priorityassignmentwherebytheearlierthedeadline,the
higherthepriority.
Thisalgorithmisimportantbecauseitisoptimalwhen
usedtoschedulejobsonaprocessorwhenpreemptionis
allowedandthereisnocontentionforresources.

EarliestDeadlineFirst(EDF)
Algorithm(2)

Whenpreemptionisallowedandjobsdonotcontendforresources,the
EDFalgorithmcanproduceafeasiblescheduleofasetofjobsJwith
arbitraryreleasetimesanddeadlinesonaprocessor,ifandonlyifJhas
feasibleschedules.
AnyfeasiblescheduleofJcanbesystematicallytransformedintoanEDF
schedule.
ToseehowwecanlookatthefigureTransformationofanonEDF
scheduleintoanEDFschedule
SupposethatinaschedulepartsofJiandJkarescheduledinintervalsI1
andI2respectively,andthatdeadlinediofJiislaterthandeadlinedkofJk,
butI1isearlierthanI2.

EarliestDeadlineFirst(EDF)
Algorithm(3)

figureTransformationofanonEDFscheduleintoan
EDFschedule

EarliestDeadlineFirst(EDF)
Algorithm(4)

Therearetwocases:
Firstcase

ThereleasetimeofJkmaybelaterthantheendofI1.
JkcannotbescheduledinI1.
The2jobsarealreadyscheduledaccordingtoEDF.

Secondcase
ThereleasetimerkofJkisbeforetheendofI1.
WithoutlossofgeneralitywecanassumethatrkisnolaterthanthebeginningofI1.

TotransformthegivenscheduleweswapJiandJk.
IfI1isshorterthanI2,wemovetheportionofJkthatfitsinI1forwardtoI1
andmovetheentireportionofJischeduledinI1backwardtoI2andplaceit
afterJk.

EarliestDeadlineFirst(EDF)
Algorithm(5)

Clearly,thisswapisalwayspossible.
WecandoasimilarswapifI1islongerthanI2.
InwhichcasewemovetheentireportionofJkscheduledinI2
toI1andplaceitbeforeJiandmovetheportionofJithatfits
inI2totheinterval.
Theresultofthisswapisthatthesetwojobsarenow
scheduledaccordingtoEDF.
Werepeatthistransformationforeverypairofjobsnot
scheduledaccordingtoEDFuntilnosuchpairexists.

EarliestDeadlineFirst(EDF)
Algorithm(6)

TheschedulesoobtainedmaystillnotbeanEDFscheduleifsomeinterval
isleftidlewhiletherearejobsreadyforexecutionbutscheduledlater.
Thisisillustratedinpart(b)ofthefigure.
Wecaneliminatesuchanidleintervalbymovingoneormoreofthesejobs
forwardintotheidleintervalandleavetheintervalwherethejobswere
scheduledidle.
Clearlythisisalwayspossible.
Werepeatthisuntiltheprocessorneveridleswhentherearejobsreadyfor
execution.
Thisisillustratedinpart(c)ofthefigure.

EarliestDeadlineFirst(EDF)
Algorithm(7)

Thisonlyworkswhenthereispreemption.
ThisisbecausethepreemptiveEDFalgorithmcanalwaysproducea
feasiblescheduleifsuchascheduleexists.
Whenthegoalistomeetdeadlinesthenthereisnoadvantagein
completinganyjobsoonerthannecessary.
Wemayevenwanttopostponetheexecutionofhardrealtimejobs
toenablesoftrealtimejobswhoseresponsetimesareimportantto
completeearlier.
ForthisreasonwesometimesusetheLatestReleaseTime(LRT)
algorithm(orreverseEDFalgorithm).

LatestReleaseTime(LRT)Algorithm
TheLatestReleaseTimealgorithmtreatsreleasetimesas
deadlinesanddeadlinesasreleasetimesandschedules
jobsbackwards,startingfromthelatestdeadlineofall
jobs,inaprioritydrivenmanner,tothecurrenttime.
Theprioritiesarebasedonthelaterthereleasetime,the
higherthepriority.
Becauseitmayleavetheprocessoridlewhenthereare
jobsawaitingexecution,theLRTalgorithmisnota
prioritydrivenalgorithm.

LRTAlgorithmExample

Inthefollowingexample,thenumbernexttothejobisthe
executiontimeandthefeasibleintervalfollowsit.
Thelatestdeadlineis8,sotimestartsat8andgoesbackto0.At
time8,J2isreadyandisscheduled.Attime7,J3isalsoready
butbecauseJ2hasalaterreleasetime,ithasahigherpriority,soJ2
isscheduledfrom7to6.
WhenJ2completesattime6,J1isreadyhoweverJ3hasa
higherprioritysoisscheduledfrom6to4.
FinallyJ1isscheduledfrom4to1.

LeastSlackTimeFirst(LST)
Algorithm
Anotheralgorithmoptimalforscheduling
preemptivejobsononeprocessoris
LeastSlackTimeFirst(LST)alsocalled
MinimumLaxityFirst(MLF).
Atanytimet,theslack(orlaxity)ofajob
withdeadlined,isequaltodtminusthe
timerequiredtocompletetheremainderof
thejob.

LeastSlackTimeFirst(LST)
Algorithm2
JobJ1fromtheLRTexampleisreleasedat
time0andhasitsdeadlineattime6and
executiontime3.
Henceitsslackis3attime0.
Thejobstartstoexecuteattime0.
Aslongasitexecutesitsslackremains3
becauseatanytimebeforeitscompletionits
slackis6t(3t)

LeastSlackTimeFirst(LST)
Algorithm3
SupposeJ1ispreemptedattime2byJ3which
executesfromtime2to4.
DuringthisintervaltheslackofJ1decreasesfrom3to
1.
Attime4theremainingexecutiontimeofJ1is1,so
itsslackis641=1.
TheLSTalgorithmassignsprioritiestojobsbasedon
theirslacks.
Thesmallertheslack,thehigherthepriority

NonoptimalityofEDFandLST
DoEDFandLSTalgorithmsremain
optimalifpreemptionisnotallowedor
thereismorethhanoneprocessor?
No!Considerthefollowing3independent
nonpreemptablejobs,J1,J2,J3,withrelease
times0,2,4andexecutiontimes3,6,4,
anddeadlines10,14,12respectively.

NonoptimalityofEDFandLST2
BothEDFandLSTwouldproducethe
infeasibleschedule(a)whereasafeasible
scheduleispossible(b).
Notethat(b)cannotbeproducedbya
prioritydrivenalgorithm

NonoptimalityofEDFfor
multiprocessors

ThistimewehavetwoprocessorsandthreejobsJ1,
J2,J3,withexecutiontimes1,1,5anddeadlines1,
2,5respectively.Allwithreleasetime0.
EDFgivestheinfeasibleschedule(a)whereasLST
givesafeasibleschedule(b)butingeneralLSTis
alsononoptimalformultiprocessors.

ValidatingTimingConstraintsin
PriorityDrivenSystems

Comparedwiththeclockdrivenapproach,theprioritydriven
schedulingapproachhasmanyadvantages:

Easytoimplement
Oftenhavesimplepriorityassignmentrules
Ifthepriorityassignmentrulesaresimple,theruntimeoverheadsof
maintainingpriorityqueuescanbesmall
Doesnotrequireinformationaboutdeadlinesandreleasetimesinadvanceso
itissuitedtoapplicationswithvaryingtimeandresourcerequirements

Ontheotherhandaclockdrivenscheduler:
Requiresinformationaboutreleasetimesanddeadlinesofjobsinadvancein
ordertoschedulethem

ValidatingTimingConstraintsin
PriorityDrivenSystems(2)

Despiteitsmerits,theprioritydrivenapproachhasnot
beenwidelyusedinhardrealtimesystems,especially
safetycriticalsystems,untilrecently.
Themainreasonforthisisthatthetimingbehaviourofa
prioritydrivensystemisnotdeterministicwhenjob
parametersvary.
Thusitisdifficulttovalidatethatthedeadlinesofalljobs
scheduledinaprioritydrivenmannerindeedmeettheir
deadlineswhenjobparametersvary.

ValidatingTimingConstraintsin
PriorityDrivenSystems(3)

Ingeneral,thevalidationproblemcanbestated:

Givenasetofjobs,thesetofresourcesavailabletothejobs,and
thescheduling(andresourceaccesscontrol)algorithmto
allocateprocessorsandresourcestojobs,determinewhetherall
thejobsmeettheirdeadlines.

Thisisaverydifficultproblemtosolvewhenyoudont
havealltheinformationaboutallthejobsavailablein
advanceandcanverifythecompletescheduleasina
clockdrivensystem.

AnomalousBehaviourofPriority
DrivenSystems
Considertheexamplein
figureillustrating
schedulinganomalies

AnomalousBehaviourofPriority
DrivenSystems(2)

Thisexampleillustrateswhythevalidationproblemisdifficultwithpriority
drivenschedulingandvaryingjobparameters.
Considerasimplesystemoffourindependentjobsscheduledontwo
processorsinaprioritydrivenmanner.
ThereisacommonpriorityqueueandthepriorityorderofjobsisJ1,J2,J3,
J4,withJ1beingofhighestpriority.
Itisadynamicsystem.
Jobsmaybepreemptedbutnevermigratedtoanotherprocessor.(acommon
characteristic)
Thereleasetimes,deadlinesandexecutiontimesorthejobsareprovidedin
thetable.

AnomalousBehaviourofPriority
DrivenSystems(3)

TheexecutiontimesofthejobsarefixedexceptforJ2whoseexecution
timeissomewhereintherange[2,6]
Supposewewanttodeterminewhetherthesystemmeetsallthedeadlines
andwhetherthecompletiontimejitterofeveryjob(i.e.thedifference
betweenthelatestandearliestcompletiontimesofthejob)is<=4.
Letussimulatethepossibleschedulestoseewhatcanhappen.
SupposeweschedulethejobsaccordingtotheirprioritiesandtryoutJ2
withitsmaximumexecutiontime6andalsowithitsminimumexecution
time2.(seethefigure(a),(b))
ItseemsOKfordeadlinesandforcompletiontimejitter.

AnomalousBehaviourofPriority
DrivenSystems(4)

Wrong!Havealookatcases(c)and(d)
AsfarasJ4isconcerned,theworstcasescheduleis(c)whenexecution
timeofJ2is3andJ4completesat21missingthedeadline.
ThebestcasescheduleforJ4is(d)whenJ2hasexecutiontime5andJ4
completesattime15,howeverthecompletiontimejitterexceedsits
limitof4.
Tofindtheworstcaseandbestcasescheduleswehavetotryall
possiblevaluesofe2.
Thisisknownasaschedulinganomaly,anunexpectedtimingbehaviour
ofprioritydrivensystems.

AnomalousBehaviourofPriority
DrivenSystems(5)

Ithasevenbeenshownthatthecompletiontimeofasetofnon
preemptivejobswithidenticalreleasetimescanbelaterwhenmore
processorsareused,andwhentheyhaveshorterexecutiontimesand
fewerdependencies.
Itcanevenhappenwithasingleprocessorandwhenjobsare
preemptablewhenjobshavearbitraryreleasetimesandshareresources.
Schedulinganomaliesmakevalidatingaprioritydrivensystemdifficult
wheneverjobparametersvary.Unfortunatelyvariationsinexecution
timesandreleasetimesareoftenunavoidable,makingprioritydriven
systemsproblematicinallbutverysmallsystems.

PriorityDrivenSystemsandPriority
Inversion

Notethatinourexampleofanomalousbehaviour,itispossibletoobtain
validschedules.Itisjustthatourprioritydrivenalgorithmscouldnotdo
it.
Forinstance,ifoneassumedthatJ4wasnotpreemptable,thencase
wouldmeetitsdeadline,butyouwouldbeviolatingtherulethatsaysthat
thehighestpriorityrunnablejobshouldberun.
InthiscaseJ4wouldcontinuerunningeventhoughthehigherpriorityJ3
wasabletorun.
Thisiscalledapriorityinversion.
Thishappenswhenalowerpriorityjobrunsinpreferencetoahigher
priorityjobwhichhastowait.

Enoughmaterialfor2001sexam
Whilewehavenotmanagedtogetthroughallthe
materialpromised(topicsinbluehavebeenomitted)we
havedonesufficientfortheallimportantexamination.
Wehavelookedat

whatrealtimesystemsare
variousclassesofrealtimesystems
howtomodelrealtimesystems
Schedulingofrealtimesystemsinvariousways

Whatelseisthere?
Therearemanymoreschedulingtechniques
available.
Someofthesehaveinterestinganduseful
properties.
Wehaveseensomebasicschedulersand
mostimportantlywehaveexaminedthe
possibleproblemsthatcanoccur.

Whatelseisthere?(2)
Apartfrommoresophisticatedscheduling
methods,thecriticalfeatureofrealtimesystem
designisinmakingeveryjobmeetitsdeadline.
Togiveusconfidenceinourschedulingweshould
trytovalidatethescheduletodeterminewhetherit
willalwayssucceedinmeetingdeadlines.
Thisisaverycomplexprocesswhichwehavenot
hadtimetocoverproperly.

Whatelseisthere?(3)
Whenwehavetheschedulingandvalidationsortedout,we
needtoactuallyimplementarealtimesystem.
Oneapproachistobuildaspecialpurposeschedulerintoour
realtimeapplication.
Anotherapproachistouseacommercialrealtimeoperating
system.
Giventhatonedoesnothavefullinformationabouthowthe
commercialsystemmightoperate,thisapproachisnot
generallyusedinsafetycriticalsystems.

Whatelseisthere?(4)
Thebiggestprobleminrealtimesystemsisvariationinjob
parameters.Thisiswhatmakesvalidationdifficultifnotimpossible.
Variationinexecutiontimeisextremelydifficultifnotimpossibleto
predictwithmodernsuperscalar,speculativeexecutionprocessors.
Insuchmachinestheworstcaseperformanceismanyordersof
magnitudeworsethanthebestcase,soifweassumetheworstcaseto
besafe,weendupwastingmostoftheprocessor.
So,oneapproachistouseacollectionofcheap,simpleprocessors,
eachdedicatedtoajob.

Whatelseisthere?(5)
Withsuchadistributedsystemofsimplemicrocontrollers,the
schedulingisnotanissuesinceyoucantaketheapproachof
allocatingadedicatedprocessorwhichisalwaysreadytorunthe
job.
Itmaynotbethecheapestapproachbutithasotheradvantagesin
termsoffaulttolerancesinceyoumightbeabletotolerateasingle
processorfailurebyreschedulingontooneofthemanyother
processors.
Thiskindofredundantcollectionofsimpleprocessorsiscommonly
usedinthesafetycriticalaerospacedomain.

Conclusion
Ihopeyouhavelearnedsomethingfromthissubject,
evenifitisonlythatrealtimesystemsarequite
difficulttomakeworkreliablyandtoanalyse.
Youshoulddotheexercisesforyourlabassignment
mark
Havealookatthesampleexaminationquestions
whichareindicativeofwhattoexpectinthereal
exam.
Andofcoursecomealongandgettherestofthe
marksinthefinalexam.