Professional Documents
Culture Documents
NPTEL Course: Real Time Systems: Model Questions and Answers 1 June, 2010
NPTEL Course: Real Time Systems: Model Questions and Answers 1 June, 2010
NPTELCourse:RealTimeSystems
ModelQuestionsandAnswers
1stJune,2010
PROF.RAJIBMALL,
DEPT.OFCSE,
IITKHARAGPUR.
Prof.R.Mall,IITKharagpur
Page1
RealTimeSystems:ModelQnA 2010
Contents
Lectures15:IntroductiontoRealTimeSystems...........................................................................3
Lectures612:RealTimeTaskScheduling......................................................................................9
Lectures1316:ResourceSharingandDependenciesamongRealTimeTasks...........................18
Lectures1720:SchedulingRealTimeTasksinMultiprocessorandDistributedSystems..........23
Lectures2130:RealTimeOperatingSystems.............................................................................29
Lectures3139:RealTimeCommunication..................................................................................36
Lecture40:RealTimeDatabases.................................................................................................42
Prof.R.Mall,IITKharagpur
Page2
RealTimeSystems:ModelQnA 2010
Lectures15:IntroductiontoRealTimeSystems
Q1:StatewhetherthefollowingstatementsareTRUEorFALSE.Justify
youranswer.
i.
Ahardrealtimeapplicationconsistsofonlyhardrealtimetasks.
FALSE.Ahardrealtimeapplicationmayalsocontainseveralnonrealtime
taskssuchasloggingactivities,etc.
ii.
Everysafetycriticalrealtimesystemcontainsafailsafestate.
FALSE. Having failsafe states in safetycritical realtime systems is
meaningless because failure of a safetycritical system can lead to loss of
lives,causedamage,etc.E.g.:anavigationsystemonboardanaircraft.
iii.
iv.
v.
Prof.R.Mall,IITKharagpur
Page3
RealTimeSystems:ModelQnA 2010
vi.
Allhardrealtimesystemsusuallyaresafetycriticalinnature.
FALSE. Not all hard realtime systems are safetycritical in nature. E.g.:
computergames,etc.
vii.
viii.
Softrealtimetasksdonothaveanyassociatedtimebounds.
FALSE. Soft realtime tasks also have time bounds associated with them.
Insteadofabsolutevaluesoftime,theconstraintsareexpressedintermsof
theaverageresponsetimesrequired.
ix.
x.
Prof.R.Mall,IITKharagpur
Page4
RealTimeSystems:ModelQnA 2010
Ans: In a realtime application, the notion of time stands for the absolute time
whichisquantifiable.Incontrasttorealtime,logicaltime,usedinmostgeneral
category applications, deals with a qualitative notion of time and are expressed
using event ordering relations. For example, consider the following part of the
behavior of library automation software used to automate the bookkeeping
activitiesofacollegelibrary:Afteraquerybookcommandisgivenbytheuser,
thedetailsofallthematchingbooksaredisplayedbythesoftware.
Q4:Explaintheimportantdifferencesbetweenhard,firmandsoftreal
timesystems.
Ans: Ahardrealtimetaskisonethatisconstrainedtoproduceitsresultswithin
certain predefined time bounds. The system is considered to have failed
whenever any of its hard realtime tasks does not produce its required results
beforethespecifiedtimebound.Unlikeahardrealtimetask,evenwhenafirm
realtimetaskdoesnotcompletewithinitsdeadline,thesystemdoesnotfail.The
late results are merely discarded. In other words, the utility of the results
computed by a realtime task becomes zero after the deadline. Soft realtime
tasksalsohavetimeboundsassociatedwiththem.However,unlikehardandfirm
realtimetasks,thetimingconstraintsonsoftrealtimetasksarenotexpressedas
absolute values. Instead, the constraints are expressed in terms of the average
responsetimesrequired.
Page5
RealTimeSystems:ModelQnA 2010
Q6:Whatisafailsafestate?Sincesafetycriticalsystemsdonothave
afailsafestate,howissafetyguaranteed?
Ans: Afailsafestateofasystemisonewhichifenteredwhenthesystemfails,
no damage would result. All traditional nonrealtime systems do have one or
morefailsafestates.
However, safetycritical systems do not have a failsafe state. A safetycritical
system is one whose failure can cause severe damages. This implies that the
reliabilityrequirementofasafetycriticalsystemisveryhigh.
Q7:Giveanexampleofanextremelysafebutunreliablesystem?
Ans: Yes,documentprocessingsoftwareisanexampleofasystemwhichissafe
butmaybeunreliable.Thesoftwaremaybeextremelybuggyandcanfailmany
times while using. But a failure of the software does not usually cause any
significantdamageoffinancialloss.
Q8: List the different types of timing constraints that can occur in a
realtimesystem?
Ans: The different timing constraints associated with a realtime system can be
broadlyclassifiedintothefollowingcategories:
1) Performanceconstraints
2) Behavioralconstraints
Prof.R.Mall,IITKharagpur
Page6
RealTimeSystems:ModelQnA 2010
Eachoftheperformanceandbehavioralconstraintscanfurtherbeclassifiedinto
thefollowingtypes:
1) Delayconstraint
2) Deadlineconstraint
3) Durationconstraint
Prof.R.Mall,IITKharagpur
Page7
RealTimeSystems:ModelQnA 2010
(b) TheEFSMmodelfortheproblemisshowninthebelowfigure.
Prof.R.Mall,IITKharagpur
Page8
RealTimeSystems:ModelQnA 2010
Lectures612:RealTimeTaskScheduling
Q1:StatewhetherthefollowingstatementsareTRUEorFALSE.Justify
youranswer.
i.
Cyclicschedulersdonotrequirestoringaprecomputedschedule
unliketabledrivenschedulers.
FALSE. A cyclic scheduler also needs to store a precomputed schedule.
However,theprecomputedscheduleneedstobestoredforonlyonemajor
cycle. Each task in the task set which repeats identically in every major
cycle.
ii.
iii.
Foranonpreemptiveoperatingsystem,RMAisanoptimalstatic
priorityschedulingalgorithmforasetofperiodicrealtimetasks.
FALSE. RMA is preemptive in nature, and hence is meaningless on a non
preemptiveoperatingsystem.
iv.
Prof.R.Mall,IITKharagpur
Page9
RealTimeSystems:ModelQnA 2010
v.
vi.
EDFpossessesgoodtransientoverloadhandingcapability.
FALSE.EDFisnotgoodinhandlingtransientoverloadconditions.Thisisa
serious drawback in the EDF scheduling algorithm. When EDF is used to
schedule a set of periodic realtime tasks, a task overshooting its
completiontimecancausesomeothertask(s)tomisstheirdeadlines.
vii.
viii.
Schedulingdecisionsaremadeonlyatthearrivalandcompletion
oftasksinanonpreemptiveeventdriventaskscheduler.
TRUE.Ineventdrivenscheduling,theschedulingpointsaredefinedbytask
completion and task arrival times. This is because during the course of
executionofataskontheCPU,thetaskcannotbepreempted.
Prof.R.Mall,IITKharagpur
Page10
RealTimeSystems:ModelQnA 2010
ix.
Foruniprocessorsystems,determininganoptimalschedulefora
set of independent periodic hard realtime tasks without any
resourcesharingconstraintsunderstaticpriorityconditionsisan
NPcompleteproblem.
FALSE.Optimalschedulingalgorithms onuniprocessorsalreadyexist(e.g.,
RMAforstaticpriority,andEDFfordynamicpriority).However,findingan
optimal schedule for a set of independent periodic hard realtime tasks
withoutanyresourcesharingconstraintsunderstaticpriorityconditionson
amultiprocessorisanNPcompleteproblem.
x.
Page11
RealTimeSystems:ModelQnA 2010
Ans: A periodic task is one that repeats after a certain fixed time interval. The
precise time instants at which periodic tasks recur are usually demarcated by
clockinterrupts.Forthisreason,periodictasksarealsoreferredtoasclockdriven
tasks.
A sporadic task is one that recurs at random instants. Each sporadic task is
characterizedbyaparametergi whichimpliesthattwoinstancesofthesporadic
taskhavetobeseparatedbyaminimumtimeofgi.Anaperiodictaskisinmany
wayssimilartoasporadictask.Anaperiodictaskcanariseatrandominstants.In
case of aperiodic tasks, the minimum separation gi between two consecutive
instancescanbe0.Also,thedeadlineforaperiodictaskisexpressedaseitheran
averagevalueorisexpressedstatistically.
Page12
RealTimeSystems:ModelQnA 2010
does not pass it on, and one which passes the output on. This method
involvessettingthesecondtasksprioritytoveryhighvaluesanditsperiod
to be the same as that of the first task. An action scheduled with this
approach will run one cycle behind schedule, but the tasks will have tight
completiontimejitter.
Q5:CanweconsiderEDFasadynamicpriorityschedulingalgorithmfor
realtimetasks?
Ans:EDFschedulingdoesnotdirectlyrequireanypriorityvaluetobecomputed
foranytaskatanytime,andinfacthasnonotionofapriorityofatask.Tasksare
scheduled solely on the proximity to their deadline. However, the longer a task
waitsinareadyqueue,thehigheristhechance(probability)ofbeingtakenupfor
scheduling.Thiscanbeconsideredtobeavirtualpriorityvalueassociatedwitha
taskwhichkeepsincreasingwithtimeuntilthetaskistakenupforscheduling.
Q6: A realtime system consists of three tasks T1, T2, and T3. Their
characteristicshavebeenshowninthefollowingtable.
Task
Phase(ms)
Execution
Time(ms)
T1
T2
T3
20
40
70
10
10
20
Relative
Deadline
(ms)
20
50
80
Period(ms)
20
50
80
Supposethetasksaretobescheduledusingatabledrivenscheduler.
Computethelengthoftimeforwhichthescheduleshavetobestored
intheprecomputedscheduletableofthescheduler.
Ans:Intabledrivenscheduling,thesizeoftheschedulethatneedstobestoredis
equal to the LCM of the periods of the individual tasks. This value is called the
majorcycleofthesetoftasks.Thetasksintheschedulewillautomaticallyrepeat
Prof.R.Mall,IITKharagpur
Page13
RealTimeSystems:ModelQnA 2010
after every major cycle. The major cycle of a set of tasks is LCM of the periods
evenwhenthetaskshavearbitraryphasing.
So,majorcycle=LCM(20,50,80)=400ms.
Q7:Usingacyclicrealtimescheduler,suggestasuitableframesizethat
can be used to schedule three periodic tasks T1, T2, and T3 with the
followingcharacteristics:
Task
Phase(ms)
T1
T2
T3
0
0
0
Execution
Time(ms)
20
20
30
Relative
Deadline(ms)
100
80
150
Period(ms)
100
80
150
Ans:Forthegiventaskset,anappropriateframesizeistheonethatsatisfiesall
therequiredconstraints.LetFbetheappropriateframesize.
Constraint1:F>=max{executiontimeofatask}
F>=30
Constraint2:ThemajorcycleMforthegiventasksetTis
M=LCM(100,80,150)=1200
MshouldbeanintegralmultipleofF.ThisconsiderationimpliesthatFcantake
onthevalues30,40,60,100,120,150,200,300,400,600,1200andstillsatisfy
Constraint1.
Constraint 3: To satisfy this constraint, we need to check whether a selected
framesizeFsatisfiestheinequality:2FGCD(F,pi)<=diforeachpi.
LetusfirsttryforF=30.
T1:2*30GCD(30,100)<=100
6010<=100
Prof.R.Mall,IITKharagpur
Page14
RealTimeSystems:ModelQnA 2010
Satisfied
T2:2*30GCD(30,80)<=80
6010<=80
Satisfied
T3:2*30GCD(30,150)<=150
6030<=150
Satisfied
Therefore, F=30 is a suitable frame size. We can carry out our computations for
theotherpossibleframesizes,i.e.F=40,60,100,120,150,200,300,400,600,
1200, to find out other possible solutions. However, it is better to choose the
shortestframesize.
Q8:Determinewhetherthefollowingsetofperiodicrealtimetasksis
schedulableonauniprocessorusingRMA.
Task
T1
T2
T3
T4
StartTime
(ms)
20
40
60
25
Processing
Time(ms)
25
7
10
10
Period(ms)
Deadline(ms)
150
40
60
30
100
40
50
20
Ans:LetusfirstcomputethetotalCPUutilizationachievedduetothegiventasks.
4
U ui
i 1
25 7 10 10
0.84 1
150 40 60 30
Therefore,thenecessaryconditionissatisfied.
Thesufficiencyconditionisgivenby
Prof.R.Mall,IITKharagpur
Page15
RealTimeSystems:ModelQnA 2010
ui n(2
i 1
Therefore,
1)
0.84 4(2
1)
0.84 0.76
Notsatisfied.
Although,thegivensetoftasksfailstheLiuandLaylandstestwhichispessimistic
innature,weneedtocarryoutLehoczkystest.
Weneedtoreorderthetasksaccordingtotheirdecreasingpriorities.
Task
T4
T2
T3
T1
StartTime
(ms)
25
40
60
20
Processing
Time(ms)
10
7
10
25
Period(ms)
Deadline(ms)
30
40
60
150
20
40
50
100
TestingfortaskT4:Sincee4<=d4,therefore,T4wouldmeetitsfirstdeadline.
40
* 10 40
30
TestingfortaskT2: 7
Satisfied.
TaskT2wouldmeetitsfirstdeadline.
60
60
* 7 * 10 50
40
30
TestingfortaskT3: 10
Satisfied.
TaskT3wouldmeetitsfirstdeadline.
150
150
150
* 10
*7
* 10 100
60
40
30
TestingfortaskT1: 25
Prof.R.Mall,IITKharagpur
Page16
RealTimeSystems:ModelQnA 2010
Notsatisfied.
Therefore,taskT1wouldfailtomeetitsfirstdeadline.
Hence,thegiventasksetisnotRMAschedulable.
Prof.R.Mall,IITKharagpur
Page17
RealTimeSystems:ModelQnA 2010
Lectures1316:ResourceSharingandDependencies
amongRealTimeTasks
Q1:StatewhetherthefollowingstatementsareTRUEorFALSE.Justify
youranswer.
i.
ii.
iii.
iv.
AtaskcanundergopriorityinversionforsomedurationunderPCP
evenifitdoesnotrequireanyresource.
Prof.R.Mall,IITKharagpur
Page18
RealTimeSystems:ModelQnA 2010
v.
vi.
vii.
HLPovercomesdeadlockswhilesharingcriticalresourcesamonga
setofrealtimetasks.
TRUE.HLPovercomesthedeadlockproblempossiblewithPIP.
viii.
UnderHLP,tasksaresingleblocking.
TRUE.WhenHLPisusedforresourcesharing,onceataskgetsaresource
required by it, it is not blocked any further. This means that when a task
acquiresoneresource,alltheotherresourcesrequiredbyitmustbefree.
ix.
UnderPCP,thehighestprioritytaskdoesnotsufferanyinversions
whensharingcertaincriticalresources.
FALSE.EvenunderPCP,thehighestpriorityprotocolcansufferfromdirect
andavoidancerelatedinversions.
Prof.R.Mall,IITKharagpur
Page19
RealTimeSystems:ModelQnA 2010
x.
UnderPCP,thelowestprioritytaskdoesnotsufferanyinversions
whensharingcertaincriticalresources.
TRUE. In PCP, the lowest priority task does not suffer from any of direct,
inheritancerelated,oravoidancerelatedinversions.
Q2:Explainpriorityinversioninthecontextofrealtimescheduling?
Ans: When a lower priority task is already holding a resource, a higher priority
task needing the same resource has to wait and cannot make progress with its
computations. The higher priority task remains blocked until the lower priority
taskreleasestherequirednonpreemptableresource.Inthissituation,thehigher
prioritytaskissaidtoundergosimplepriorityinversiononaccountofthelower
prioritytaskforthedurationitwaitswhilethelowerprioritytaskkeepsholding
theresource.
Q3: What can be the types of priority inversions that a task might
undergoonaccountofalowerprioritytaskunderPCP?
Ans: Tasks sharing a set of resources using PCP may undergo three important
types of priority inversions: direct inversion, inheritancerelated inversion, and
avoidanceinversion.
Directinversionoccurswhenahigherprioritytaskwaitsforalowerprioritytask
to release a resource that it needs. Inheritancerelated inversion occurs when a
lowerprioritytaskisholdingaresourceandahigherprioritytaskiswaitingforit.
Then,thepriorityofthelowerprioritytaskisraisetothatofthewaitinghigher
priority task by the inheritance clause of the PCP. As a result, the intermediate
prioritytasksnotneedingtheresourceundergoinheritancerelatedinversion.
In PCP, when a task requests a resource its priority is checked against CSC. The
requesting task is granted use of the resource only when its priority is greater
than CSC. Therefore, even when a resource that a task is requesting is idle, the
requesting task may be denied access to the resource if the requesting tasks
priority is less than CSC. A task, whose priority is greater than the currently
Prof.R.Mall,IITKharagpur
Page20
RealTimeSystems:ModelQnA 2010
executingtask,butlesserthantheCSCandneedsaresourcethatiscurrentlynot
inuse,issaidtoundergoavoidancerelatedinversion.
Q5:CanPIPandPCPbeconsideredasgreedyalgorithms?
Ans: In PIP, whenever a request for a resource is made, the resource will be
allocatedtotherequestingtaskifitisfree.However,inPCParesourcemaynot
begrantedtoarequestingtaskeveniftheresourceisfree.ThisstrategyinPCP
helpsinavoidingpotentialdeadlocks.
Q6:Thefollowingtableshowsthedetailsoftasksinarealtimesystem.
The tasks have zero phasing and repeat with a period of 90 ms.
Determineafeasiblescheduletobeusedbyatabledrivenscheduler.
Prof.R.Mall,IITKharagpur
Page21
RealTimeSystems:ModelQnA 2010
ComputationTime
ei(ms)
30
15
20
10
Task
T1
T2
T3
T4
Deadlinedi(ms)
Dependency
90
40
40
70
T1,T3
T1
T2
Ans:
Step1:Sortthetasksinincreasingorderoftheirdeadlines.
T2T3T4T1
Step2:Scheduletasksaslateaspossiblewithoutviolatingconstraints.
T2
5
T3
20
T1
40
T4
50 60
90
Step3:Movetasksasearlyaspossiblewithoutalteringtheschedule.
15
35 45
Prof.R.Mall,IITKharagpur
75
Page22
RealTimeSystems:ModelQnA 2010
Lectures1720:SchedulingRealTimeTasksin
MultiprocessorandDistributedSystems
Q1:StatewhetherthefollowingstatementsareTRUEorFALSE.Justify
youranswer.
i.
ii.
iii.
iv.
Prof.R.Mall,IITKharagpur
Page23
RealTimeSystems:ModelQnA 2010
FALSE.Focusedaddressingandbiddingalgorithmusedforallocatingtasks
indistributedrealtimesystemsisadynamicallocationtechnique.
v.
Dynamictaskarrivalscanefficientlybehandledusingthefocused
addressing and bidding algorithm in multiprocessorbased real
timesystems.
TRUE.
vi.
ThecommunicationoverheadincurredduetoBuddyalgorithmsis
less compared to focused addressing and bidding algorithms in
multiprocessorrealtimetaskscheduling.
TRUE.
vii.
Inadistributedsystem,allocatingasetofrealtimetaskscanbe
doneoptimallyusingthebinpackingalgorithm.
FALSE. Determining an optimal schedule for a set of realtime tasks on a
multiprocessororadistributedsystemisanNPhardproblem.
viii.
Page24
RealTimeSystems:ModelQnA 2010
Ans:Abasicdifferencebetweenmultiprocessoranddistributedsystemsissharing
of physical memory. Multiprocessor systems (aka. tightlycoupled systems) are
characterized by the existence of a shared physical memory. In contrast, a
distributedsystem(aka.looselycoupledsystem)isdevoidofanysharedphysical
memory. In a tightlycoupled system, the interprocess communication is
inexpensive and is achieved through read and writes to the shared memory.
However, the same is not true for distributed systems where intertask
communicationtimesarecomparabletothetaskexecutiontimes.Duetothis,a
multiprocessor system may use a centralized scheduler/dispatcher whereas a
distributedsystemcannot.
Q3:Whatisitrequiredtosynchronizetheclocksinadistributedreal
time system? Compare the advantages and disadvantages of
centralizedandthedistributedclocksynchronization.
Ans: Besides the traditional use of clocks in a computer system, clocks are also
usedfordeterminingtimeoutsandtimestamping.However,differentclocksina
distributedsystemtendtodivergesinceitisalmostimpossibletohavetwoclocks
that run exactly at the same speed. This lack of synchrony among clocks is
expressed as the clock skew and determines the attendant drifts of the clocks
withtime.Lackofsynchronyanddriftamongclocksmakesthetimestampingand
timeout operations in a distributed realtime system meaningless. Therefore, to
havemeaningfultimeoutsandtimestampingspanningmorethanonenodeofa
distributedsystem,theclocksneedtobesynchronized.
The main problem with centralized clock distribution scheme is that it is
susceptible to single point failure. Any failure of the master clock causes
breakdown of the synchronization scheme. Distributed clock synchronization
overcomes this handicap by periodically exchanging the clock readings of each
node. However, distributed clock synchronization needs to take care of the fact
that some nodes may have bad or byzantine clocks. A disadvantage of the
distributed clock synchronization is the larger communication overhead that is
incurredinsynchronizingclocksascomparedtothecentralizedscheme.
Prof.R.Mall,IITKharagpur
Page25
RealTimeSystems:ModelQnA 2010
Page26
RealTimeSystems:ModelQnA 2010
Q6:Inadistributedsystemwithsixclocks,themaximumdifferenceof
between any two clocks is 10 ms. The individual clocks have a
maximum rate of drift of 2 * 106. Ignore clock setup times and
communicationlatencies.
a) Whatistherateatwhichtheclocksneedtoresynchronizeusing
i. asimplecentraltimeservermethod?
b) What is the communication overhead in each of the two
schemes?
Ans:
a) i)WhenclocksareresynchronizedeveryTs,maximumdriftbetweenany
b)
twoclocksislimitedto2T=.
2*2*106*T=10*103
T = (10*10-3)/2*2*10-6
T = 2500 s.
i) Master time server transmits (n1) = 5 messages per resynchronization
interval.
Numberofresynchronizationintervalsperhour=(60*60)/2500=1.44.
Numberofmessagestransmittedperhour=1.44*5=7.2 8.
Prof.R.Mall,IITKharagpur
Page27
RealTimeSystems:ModelQnA 2010
Ans:
Weknowthat
T=/2n
T=103/(2*10*5*106)
T = 10 s.
Numberofmessagestransmittedperhour=86.41*132=11406.
Prof.R.Mall,IITKharagpur
Page28
RealTimeSystems:ModelQnA 2010
Lectures2130:RealTimeOperatingSystems
Q1:StatewhetherthefollowingstatementsareTRUEorFALSE.Justify
youranswer.
i.
ii.
iii.
iv.
Computationintensivetasksdynamicallytakeonhigherpriorities
inUnix.
FALSE. Under the Unix operating system, i/o bound tasks are assigned
higherprioritiestokeepthei/ochannelsasbusyaspossible.
v.
Prof.R.Mall,IITKharagpur
Page29
RealTimeSystems:ModelQnA 2010
vi.
Taskswitchingtimeontheaverageislargerthantaskpreemption
time.
FALSE.Taskswitchingisapartofthetotaltimetakentopreemptatask.In
addition, task preemption also requires comparing the priorities of the
currentlyrunningtaskandthetasksinthereadyqueue.
vii.
viii.
POSIXbyANSI/IEEEenablesexecutablefilestobeportableacross
differentUnixmachines.
FALSE.ThemaingoalofPOSIXisapplicationportabilityatthesourcecode
level.
ix.
InanimplementationofPCPattheuserlevel,halfoftheavailable
priority levels are meaningfully assigned to the tasks if FIFO
schedulingisnotsupportedbytheoperatingsystemamongequal
prioritytasks.
TRUE.Ifthehighestpriorityamongalltasksneedingaresourceis2*n,then
theceilingpriorityoftheresourceis2*n+1.
x.
Forarealtimeoperatingsystemwhichdoesnotsupportmemory
protection, a procedure call and a system call are
indistinguishable.
TRUE.
Prof.R.Mall,IITKharagpur
Page30
RealTimeSystems:ModelQnA 2010
xi.
Watchdogtimersareusedtostartsensorandactuatorprocessing
tasksatregularintervals.
FALSE.Watchdogtimersareusedtodetectifataskmissesitsdeadline,and
then to initiate exception handling procedures upon a deadline miss. It is
also used to trigger a system reset or other corrective action if the main
programhangsduetosomefaultcondition.
Q2:Listtheimportantfeaturesthatarerequiredtobesupportedbya
RTOS.
Ans: The following is a list of the important features that an RTOS needs to
support:
Realtimeprioritylevels
Fasttaskpreemption
Predictableandfastinterruptlatency
Supportforresourcesharingamongrealtimetasks
Requirementsonmemorymanagement
SupportforasynchronousI/O
Q3: What is the difference between synchronous and asynchronous
I/O?Whichoneisbettersuitedforuseinrealtimeapplications?
Ans: Asynchronous I/O means nonblocking I/O. Under synchronous I/O system
calls, a process needs to wait till the hardware has completed the physical I/O.
Thus, in case of synchronous I/O, the process is blocked while it waits for the
resultsofthesystemcall.
Ontheotherhand,ifaprocessusesasynchronousI/O,thenthesystemcallwill
returnimmediatelyoncetheI/Orequesthasbeenpasseddowntothehardware
orqueuedintheoperatingsystemtypicallybeforethephysicalI/Ooperationhas
evenbegun.Theexecutionoftheprocessisnotblockedbecauseitdoesnotneed
Prof.R.Mall,IITKharagpur
Page31
RealTimeSystems:ModelQnA 2010
towaitfortheresultsofthesystemcall.ThishelpsinachievingdeterministicI/O
timesinanRTOS.
Q4:Describeanopensystem?Howdoesanopensystemcomparewith
aclosesystem?
Ans: An open system is a vendorneutral environment which allows users to
intermix hardware, software, and networking solutions from different vendors.
Open systems are based on open standards and are not copyrighted. The
importantadvantagesofanopensystemoveraclosedsystemareinteroperability
and portability. Other advantages are that it reduces the cost of system
developmentandthetimetomarketaproduct.Ithelpsincreasetheavailability
ofaddon software packages, enhances theease ofprogrammingandfacilitates
easyintegrationofseparatelydevelopedmodules.
Q6: What are the drawbacks in using Unix kernel for developing real
timeapplications?
Prof.R.Mall,IITKharagpur
Page32
RealTimeSystems:ModelQnA 2010
Ans: ThefollowingarethemajorshortcomingsinusingtraditionalUnixforreal
timeapplicationdevelopment:
Nonpreemptive kernel Unix kernel is nonpreemptive, i.e., a process
running in the kernel mode cannot be preempted by other processes. A
consequence of this is that even when a low priority process makes a
systemcall,thehighpriorityprocesseswouldhavetowaituntilthesystem
call by the low priority process completes. For realtime applications, this
leadstopriorityinversion.
DynamicprioritylevelsIntraditionalUnixsystems,realtimetaskscannot
be assigned static priority values. Soon after a programmer sets a priority
valueforatask,theOSkeepsonalteringitduringthecourseofexecution
of the task. This makes it very difficult to schedule realtime tasks using
algorithmssuchasEDForRMA.
InsufficientdevicedriversupportInUnix(SystemV),devicedriverrunsin
kernel mode. Therefore, if support for a new device is to be added, then
thedrivermodulehastobelinkedtothekernelmodulesnecessitatinga
systemgenerationstep.
Lack of realtime file services In Unix, file blocks are allocated as and
whentheyarerequestedbyanapplication.Asaconsequence,whileatask
is writing to a file, it may encounter an error when the disk runs out of
space. In other words, no guarantee is given that disk space would be
available when a task writes a block to a file. Traditional file writing
approachesalsoresultinslowwritesbecausetherequiredspacehastobe
allocated before writing a block. Another problem with traditional file
systemsisthatblocksofthesamefilemaynotbecontiguouslylocatedon
the disk. This would result in read operations taking unpredictable times,
resultinginjitterindataaccess.
Page33
RealTimeSystems:ModelQnA 2010
Q8:Whyisdynamicallychangingtheprioritylevelsoftasksimportant
for traditional operating systems? How does this property affect real
timesystems?
Ans: One major design decision in traditional operating systems is to provide
acceptableresponsetimestoalltheuserprocesses.Itisnormallyobservedthat
I/O transfer rate is primarily responsible for the slow response time. Processors
areextremelyfastcomparedtothetransfertimesofI/Odevices.Tomitigatethis
problem,itisdesirabletokeeptheI/Ochannelsasbusyaspossible.Thiscanbe
achieved by assigning the I/O bound tasks high priorities. To keep the I/O
channelsbusy,anytaskperformingI/Oshouldnotbekeptwaitingverylongfor
theCPU.Forthisreason,assoonasthetaskblocksforI/O,itspriorityisincreased
by a priority recomputation rule. This gives the interactive users good response
time.
However,forhardrealtimesystemsdynamicshiftingofpriorityvaluesisclearly
inappropriate, as it prevents tasks being constantly scheduled at high priority
levels, and also prevents scheduling under popular realtime task scheduling
algorithmssuchasEDFandRMA.
Prof.R.Mall,IITKharagpur
Page34
RealTimeSystems:ModelQnA 2010
Q9:Explainthedifferencesbetweenasystemcallandafunctioncall?
Whatproblemsmayariseifasystemcallismadeindistinguishablefrom
afunctioncall?
Ans:Applicationprogramsinvokeoperatingsystemservicesthroughsystemcalls.
Examplesofsystemcallsincludeoperatingsystemservicesforcreatingaprocess,
I/Ooperations,etc.This isbecausecertainoperationscanonlybe performedin
thekernelmode.
In many embedded systems, kernel and user processes execute in the same
address space, i.e., there is no memory protection. This makes debugging
applicationsdifficult,sincearunawaypointercancorrupttheoperatingsystem
codemakingthesystemfreeze.
Prof.R.Mall,IITKharagpur
Page35
RealTimeSystems:ModelQnA 2010
Lectures3139:RealTimeCommunication
Q1:StatewhetheryouconsiderthefollowingstatementstobeTRUEor
FALSE.Justifyyouranswerineachcase.
i.
ii.
iii.
Themaximumdelaysufferedbythehighestprioritypacketsata
switch when a multilevel FIFO queuebased service discipline is
deployedisgenerallylowercomparedthanwhenaframingbased
servicedisciplineisdeployed.
TRUE.MultilevelFIFOqueuebasedserviceisaworkconservingdiscipline,
while framingbased discipline is of type nonwork conserving. Work
conserving disciplines usually cause less delay than nonwork conserving
disciplines.
iv.
Prof.R.Mall,IITKharagpur
Page36
RealTimeSystems:ModelQnA 2010
v.
vi.
RMAschedulingofrealtimemessagesisineffectiveunderglobal
prioritybasedmessagetransmission.
TRUE. RMA or EDF scheduling can be used with a global prioritybased
message transmission but the achieved schedulable utilization of the
channelwouldbeverylow.
vii.
viii.
ix.
Prof.R.Mall,IITKharagpur
Page37
RealTimeSystems:ModelQnA 2010
TRUE.
x.
Inanypracticalrealtimecommunicationprotocol,theGPisclose
to0forutilizationlowerthantheABUandGPiscloseto1asthe
utilizationincreasesbeyondABU.
FALSE.TheGP(U)iscloseto1forutilizationlowerthanABU,andapproach
0asutilizationincreasesbeyondABU.
Q3:Distinguishtrafficshapingandpolicing.
Ans: Rate control can be achieved using either traffic shaping or policing. The
maindifferencesbetweenshapingandpolicingaregiveninthefollowingtable.
Objective
HandlingBursts
Advantage
Disadvantage
Shaping
Policing
Prof.R.Mall,IITKharagpur
Page38
RealTimeSystems:ModelQnA 2010
Q4:WhatismeantbyQoSrouting?
Ans:TheprimarygoalsofQoSroutingorconstraintbasedroutingare
ToselectroutesthatcanmeettheQoSrequirementsofaconnection.
Toincreasetheutilizationofthenetwork.
Whiledeterminingaroute,QoSroutingschemesnotonlyconsiderthetopology
of a network, but also the requirements of the flow, the resource availability at
thelinks,etc.Therefore,QoSroutingwouldbeabletofindalongerandlightly
loaded path rather than the shortest path that may be heavily loaded. QoS
routing schemes are, therefore, expected to be more successful than the
traditional routing schemes in meeting QoS guarantees requested by the
connections.
Q6: A realtime network consists of four nodes, and uses IEEE 802.4
protocol. The realtime requirement is that node Ni should able to
transmituptobibitsovereachperiodofdurationPims,wherebiandPi
aregiveninthetablebelow.
Prof.R.Mall,IITKharagpur
Page39
RealTimeSystems:ModelQnA 2010
Node
bi
Pi
N1
N2
N3
N4
1K
4K
16K
16K
10000
50000
90000
90000
ComputeasuitableTTRTandobtainsuitablevaluesoffi(totalnumber
of bits that can be transmitted by node Ni once every cycle). Assume
that the propagation time is compared to TTRT and that the system
bandwidthis1Mbps.
Ans: Fromanexaminationoftherequirements,itcanbeseenthattheshortest
deadline among all messages is 10000ms. Therefore, we can select TTRT =
10000/2=5s.Thechannelutilizationduetothedifferentnodeswouldbe:
C1
1
Kb / s
T 1 10
C2
4
Kb / s
T 2 50
C 3 16
Kb / s
T 3 90
C 4 16
Kb / s
T 4 90
C1 C 2 C3 C 4 1 5 16 16 66
Kb / s
T 1 T 2 T 3 T 4 10 16 90 90 90
Thetokenholdingtimes(Hi)ofthedifferentnodescanbedeterminedasfollows:
H1=5*(1/10)*(90/66)=45/66s
H2=5*(5/16)*(90/66)=125/66s
Prof.R.Mall,IITKharagpur
Page40
RealTimeSystems:ModelQnA 2010
H3=5*(16/90)*(90/66)=80/66s
H4=5*(16/90)*(90/66)=80/66s
f1=H1*1Mbps=45/66*1Mb=681.82Kb
f2=H2*1Mbps=125/66*1Mb=1893.94Kb
f3=H3*1Mbps=80/66*1Mb=1212.12Kb
f4=H4*1Mbps=80/66*1Mb=1212.12Kb
(,)modelInthismodel,isthemaximumburstsizeandisthelong
term average rate of the traffic source. Average traffic is calculated by
observing the number of packets generated over a sufficiently large
durationanddividingthisbythesizeoftheduration.Aconnectionwould
satisfy (, ) model if during any interval of length t, the number of bits
generated by the connectivity in that interval is less than + *t. This
modelcansatisfactorilybeusedtomodelburstytrafficsources.
Prof.R.Mall,IITKharagpur
Page41
RealTimeSystems:ModelQnA 2010
Lecture40:RealTimeDatabases
Q1:StatewhetherthefollowingstatementsareTRUEorFALSE.Justify
youranswerineachcase.
i.
Inrealtimeapplications,asetoftemporaldatathatisabsolutely
consistentisguaranteedtoberelativelyconsistent.
FALSE. The consistency relations are different for absolute and relative
consistency.
ii.
iii.
2PLWPprotocolisfreefromdeadlocks.
FALSE.ThefollowingexampleshowstwotransactionsT1andT2whichneed
accesstotwodataitemsd1andd2.
T1:Lockd1,Lockd2,Unlockd2,Unlockd1
T2:Lockd2,Lockd1,Unlockd1,Unlockd2
AssumethatT1hashigherprioritythanT2.T2startsrunningfirstandlocks
dataitemd2.Aftersometime,T1locksd1andthentriestolockd2whichis
beingheldbyT2.AsaconsequenceT1blocks,andT2needstolockthedata
itemd1beingheldbyT1.Now,thetransactionsT1andT2aredeadlocked.
Prof.R.Mall,IITKharagpur
Page42
RealTimeSystems:ModelQnA 2010
iv.
2PLHPprotocolisfreefrompriorityinversionanddeadlocks.
TRUE.
v.
vi.
vii.
BeforeacommittingtransactioncancommitinOCCBCprotocol,
thetransactionneedstocheckforpossibleconflictswithalready
committedtransactions.
FALSE.InOCCBCprotocol,thereisnoneedforthecommittingtransaction
to check for conflicts with already committed transactions, because if it
were in conflict with any of the committed transactions, it would have
alreadybeenaborted.
viii.
ix.
Prof.R.Mall,IITKharagpur
Page43
RealTimeSystems:ModelQnA 2010
x.
OCCprotocolsarefreefromdeadlocks.
TRUE.
xi.
Q2:Listtheimportantdifferencesbetweenarealtimedatabaseanda
conventionaldatabase?
Ans: Thefollowingarethemaindifferencesbetweenarealtimedatabaseanda
conventionaldatabase:
Unlike traditional databases, timing constraints are associated with the
differentoperationscarriedoutonrealtimedatabases.
Realtime databases have to deal with temporal data compared to static
dataasinthecaseoftraditionaldatabases.
Theperformancemetricsthataremeaningfultothetransactionsofthese
twotypesofdatabasesareverydifferent.
Q3:Discusswhichcategoryofconcurrencyprotocolisbestsuitedunder
whatcircumstances?
Ans: Lockingbased concurrency protocols tend to reduce the degree of
concurrentexecutionoftransactionsastheyconstructserializableschedules.On
the other hand, optimistic approaches attempt to increase parallelism to its
maximum, but they prune some of the transactions in order to satisfy
serializability.In2PLHP,atransactioncouldberestarted byorwaitforanother
transaction that will be aborted later. Such restarts and/or waits cause
performancedegradation.
Unlike2PLHP,inoptimisticapproacheswhenincorporatingbroadcastingcommit
schemes, only validating transactions can cause restart of other transactions.
Prof.R.Mall,IITKharagpur
Page44
RealTimeSystems:ModelQnA 2010
Page45
RealTimeSystems:ModelQnA 2010
relatively consistent, since for velocity and acceleration: (25502425) is not less
than100.
Prof.R.Mall,IITKharagpur
Page46