DCAP608_real Time System

download DCAP608_real Time System

of 237

Transcript of DCAP608_real Time System

  • 7/27/2019 DCAP608_real Time System

    1/237

    www.lpude.in

    DIRECTORATE OF DISTANCE EDUCATION

    REAL TIME SYSTEMS

  • 7/27/2019 DCAP608_real Time System

    2/237

    Copyright 2012, Navneet Kumar Singh and Amrita SinghAll rights reserved.

    Produced & Printed byFRANK BROTHERS & CO. (PUBLISHERS) LIMITED

    B-41, Sector-4, NOIDA - 201301, Gautam Budh Nagarfor

    Directorate of Distance EducationLovely Professional University

    Phagwara

  • 7/27/2019 DCAP608_real Time System

    3/237

    Directorate of Distance Education

    LPU is reaching out to the masses by providing an intellectual learning environment that is academically rich with most

    affordable fee structure. Supported by the largest University1 in the country, LPU, the Directorate of Distance Education (DDE) is

    bridging the gap between education and the education seekers at a fast pace, through the usage of technology which signicantly

    extends the reach and quality of education. DDE aims at making Distance Education, a credible and valued mode of learning,by providing education without a compromise.

    DDE is a young and dynamic wing of the University, lled with energy, enthusiasm, compassion and concern. Its team strives

    hard to meet the demands of the industry, to ensure quality in curriculum, teaching methodology, examination and evaluation

    system, and to provide the best of services to its students. DDE is proud of its values, by virtue of which, it ensures to make an

    impact on the education system and its learners.

    Through affordable education, online resources and a network of Study Centres, DDE intends to reach the unreached.

    1. in terms of no. of students in a single campus

  • 7/27/2019 DCAP608_real Time System

    4/237

    SYLLABUS

    Real Time Systems

    Objectives: To enable the students to understand the technicalities of Real Time Systems. Student can identify real time tasks

    and their criticalness. Student will learn various real time task scheduling techniques.

    S. No. Description

    1. Introduction to Real Time Applications: Digital Control, High Levels Control, Signal Processing, Other RealTime Applications.

    2. Hard Versus Soft Real-Time System:Jobs and Processors, Release Time, Deadline and Timing constraints,Hard and Soft Timing constraints, Hard real time systems, Soft real time systems.

    3. A Reference Model of Real Time System: Processors and Resources, Temporal Parameters of real time model,Precedence constraints and data dependencies.

    4. Other Types of dependences, Functional parameters, Resource parameters of jobs and parameters of resources,scheduling hierarchy.

    5. Commonly used Approaches to Real Time Scheduling: Clock-Driven approach, Weight Round-RobinApproach, Priority-Driven Approach, Dynamic versus Static system, Effective Release Times and Deadlines.

    6. Commonly used Approaches to Real Time Scheduling: Optimality of the EDF and LST Algorithm,Nonoptimility of the EDF and the LST Algorithm, Challenges in validating Timing Constraints in Priority-Driven System, Off-Line versus On Line Scheduling.

    7. Clock-Driven Scheduling: Notations and Assumptions, Static, Timer-Driven Scheduler, General Structure ofCyclic Scheduler, Cyclic Scheduling.

    8. Clock-Driven Scheduling: Improving the Average Response Time of Aperiodic jobs, Scheduling Sporadic Jobs,Practical Consideration and Generalizations, Algorithm for Constructing Static Schedules, Pros and Cons ofClock Driven Scheduling.

    9. Priority Driven Scheduling of Periodic Tasks: Static Assumptions, Fixed Priority versus Dynamic PriorityAlgorithms, Maximum Schedulable Utilization, Optimality of the RM and DM Algorithms, A Schedulability

    Test for Fixed-Priority Tasks with Short Response Time.

    10. Priority Driven Scheduling of Periodic Tasks: Schedulability Test for Fixed--Priority Tasks with ArbitraryResponse Time, Sufcient Schedulability conditions for the RM and DM Algorithm, Practical Factors

  • 7/27/2019 DCAP608_real Time System

    5/237

    CONTENTS

    Unit 1: Concept of Real Times System 1

    Unit 2: Introduction to Real Time Applications 13

    Unit 3: Hard Versus Soft Real-Time System 38

    Unit 4: A Reference Model of Real-Time Systems 59

    Unit 5: Real Time System Dependencies 74

    Unit 6: Commonly used Approaches to Real Time Scheduling 88

    Unit 7: Commonly used Algorithm to Real Time Scheduling 100

    Unit 8: Working of Real-Time Scheduling 113

    Unit 9: Concept of Clock-Driven Scheduling 126

    Unit 10: Working of Clock-Driven Scheduling 137

    Unit 11: Application of Clock-Driven Scheduling 151

    Unit 12: Priority-Driven Scheduling of Periodic Tasks 165

    Unit 13: Working of Priority Driven Scheduling of Periodic Tasks 181

    Unit 14: Advance Priority Driven Scheduling of Periodic Tasks 198

  • 7/27/2019 DCAP608_real Time System

    6/237

    6 LOVELY PROFESSIONAL UNIVERSITY

    Corporate and Business Law

  • 7/27/2019 DCAP608_real Time System

    7/237

    LOVELY PROFESSIONAL UNIVERSITY 1

    NotesUnit 1: Concept of Real Times System

    CONTENTS

    Objectives

    Introduction

    1.1 Real Time Systems

    1.2 Hard Real Time Systems

    1.3 Soft Real Time Systems

    1.4 Hard Versus Soft Real Time System

    1.5 Summary

    1.6 Keywords

    1.7 Further Reading

    Objectives

    After studying this unit, you will be able to:

    Understandthestructureandcomponentsofrealtimesystem

    Explainhardandsoftrealtimesystem

    Describethedifferencesbetweenhardandsoftrealtimesystem

    Introduction

    Arealtimeapplicationisanapplicationwherethecorrectnessoftheapplicationdependsonthe

    timelinesandpredictabilityoftheapplicationaswellastheresultsofcomputations.Toassistthe

    realtimeapplicationdesignerinmeetingthesegoals,toolsthatprovidefeaturesthatfacilitate

    efcientinterprocesscommunicationandsynchronization,a fast interruptresponse time,

    asynchronousinputandoutput(I/O),memorymanagementfunctions,lesynchronization,and

    facilitiesforsatisfyingtimingrequirementsetc.Realtimeapplicationsarebecomingincreasingly

    importantinourdailylivesandcanbefoundinvariousenvironmentssuchasautomotive

    applications,medicalequipmentetc.

    RealTimethetermisusedtodescribeanumberofdifferentcomputerfeatures.Forexample,

    real-timeoperatingsystemsaresystemsthatrespondtoinputimmediately.Theyareusedfor

    suchtasksasnavigation,inwhichthecomputermustreacttoasteadyowofnewinformation

    withoutinterruption.Mostgeneral-purposeoperatingsystemsarenotreal-timebecausetheycantakeafewseconds,orevenminutes,toreact.

    Realtimecanalsorefertoeventssimulatedbyacomputeratthesamespeedthattheywould

    occurinreallife.Ingraphicsanimation,forexample,areal-timeprogramwoulddisplayobjects

    movingacrossthescreenatthesamespeedthattheywouldactuallymove.

    RealtimeSystem,isasystemwhenitcansupporttheexecutionofapplicationswithtime

    constraintson thatexecution.Therecanbe madeaclassication intohardandsoftreal-time

    systemsbasedontheirproperties;eachofthemisexplainedwiththespecicexample.

    Areal-timesystemisanyinformationprocessingsystemwhichhastorespondtoexternally

    generatedinputstimuliwithinaniteandspeciedperiod.

  • 7/27/2019 DCAP608_real Time System

    8/237

    Real Time Systems

    2 LOVELY PROFESSIONAL UNIVERSITY

    Notes Thecorrectnessdependsnotonlyonthelogicalresultbutalsothetimeitwasdelivered.

    Failuretorespondisasbadasthewrongresponse!

    Areal-timesystemrespondsina(timely)predictablewaytounpredictableexternalstimuli

    arrivals.Inshort,areal-timesystemhastofulllunderextremeloadconditions:

    1. Timeliness:meetdeadlines,itisrequiredthattheapplicationhastonishcertaintasks

    withinthetimeboundariesithastorespect.

    2. Simultaneity or simultaneous processing:morethanoneeventmayhappensimultaneously,

    all deadlines should be met.

    3. Predictability:thereal-timesystemhastoreacttoallpossibleeventsinapredictableway.

    4. Dependability or trustworthiness:itisnecessarythatthereal-timesystemenvironmentcan

    relay on it.

    Real-time systems are systems with timing constraints

    Figure 1.1: Constraints of Real Time System

    Event

    Maximum response time

    Eventandmaximumresponsetime(Constraints),boundsonexecutiontimevariation.

    Anexampleofahardrealtimesystemisadigitaly-by-wirecontrolsystemofanaircraft:No

    latenessisacceptedunderanycircumstances;otherwisetheaircraftisnotcontrollable.Useless

    resultsiflateandnotcontrolthesystemandnotrespondtimely,theresultisaholeintheground.

    Catastrophicfailure,whichneedsnoexplanationinthecaseofanaircraftcrash.Costofmissingdeadlineisinnitelyhigh;thelivesofpeopledependonthecorrectworkingofthecontrolsystem

    of the aircraft.

    Asoftreal-timesystemcanbeavendingmachine,risingcostforlatenessofresults:Asitwill

    takelongertotreatacustomerwhentheperformanceofthevendingmachineisdegrading,less

    customerspayatthismachinewhichresultsinlessprotsfortheshopowner.Acceptlower

    performanceforlateness,itisnotcatastrophicwhendeadlinesarenotmet.Itwilltakelongerto

    handle one client with the vending machine.

    Other real-time systems examplesarenuclearpowerplantcontrol,industrialmanufacturing

    control,medicalmonitoring,weapondeliverysystem,spacenavigationandguidance,

    reconnaissancesystems,laboratoryexperimentscontrol,automobileenginescontrol,robotics,

    telemetrycontrolsystems,printercontrollers,anti-lockbreaking,burglaralarms.

    Anoperatingsystem(OS)is responsibleformanagingthehardwareresourcesofacomputer

    andhostingapplicationsthatrunonthecomputer.AnRTOSperformsthesetasks,butisalso

    speciallydesignedtorunapplicationswithveryprecisetimingandahighdegreeofreliability.

    Thiscanbeespeciallyimportantinmeasurementandautomationsystemswheredowntimeis

    costlyoraprogramdelaycouldcauseasafetyhazard.

    Tobeconsideredreal-time,anoperatingsystemmusthaveaknownmaximumtimeforeachof

    theoperationsthatitperforms(oratleastbeabletoguaranteethatmaximummostofthetime).

    SomeoftheseoperationsincludeOScallsandinterrupthandling.Operatingsystemsthatcan

    absolutelyguaranteeamaximumtimefortheseoperationsarereferredtoashardreal-time,

    whileoperatingsystemsthatcanonlyguaranteeamaximummostofthetimearereferredtoas

    softreal-time.Tofullygrasptheseconcepts,itishelpfultoconsideranexample.

  • 7/27/2019 DCAP608_real Time System

    9/237

    Unit 1: Concept of Real Times System

    LOVELY PROFESSIONAL UNIVERSITY 3

    NotesImaginethatyouaredesigninganairbagsystemforanewmodelofcar.Inthiscase,asmallerror

    intiming(causingtheairbagtodeploytooearlyortoolate)couldbecatastrophicandcauseinjury.

    Therefore,ahardreal-timesystemisneeded.Ontheotherhand,ifyouweretodesignamobile

    phonethatreceivedstreamingvideo,itmaybeoktoloseasmallamountofdataoccasionally

    eventhoughonaverageitisimportanttokeepupwiththevideostream.Forthisapplication,asoftreal-timeoperatingsystemmaysufce.

    Themainpointisthat,ifprogramedcorrectly,anRTOScanguaranteethataprogramwillrun

    withveryconsistenttiming.Real-timeoperatingsystemsdothisbyprovidingprogramerswith

    ahighdegreeofcontroloverhowtasksareprioritized,andtypicallyalsoallowcheckingtomake

    surethatimportantdeadlinesaremet.

    AnOSthatcanabsolutelyguaranteeamaximumtimefortheoperationsitperformsisreferred

    toashardreal-time.Incontrast,anOSthatcanusuallyperformoperationsinacertaintimeis

    referred to as soft real-time.

    Self Assessment

    Choose the correct answer:

    1. The correctness of the applicationdependsonthe.andpredictabilityofthe

    application.

    (a) timelines (b) deadline

    (c) bothaandb (d) noneofthese

    2. Realtimetermisusedtodescribeanumberofdifferentcomputerfeatures.

    (a) True (b) False

    3. Operatingsystemisresponsibleformanagingthehardwareresourcesofacomputerand

    .thatrunonthecomputer.

    (a) hardwarecomponent (b) hostingapplications

    (c) bothaandb (d) noneofthese

    4. Asystemisareal-timesystemwhenitcansupportthe.with time constraints on

    thatexecution.

    (a) analogsignal (b) digitalsignals

    (c) bothaandb (d) executionofapplications.

    5. Areal-timesystemmayanyinformationprocessingsystem.

    (a) True (b) False

    1.1 Real Time Systems

    Anysystemwhereatimelyresponsebythecomputertoexternalstimuliinvitalisarealtime

    system.

    Example:ACAR-AND-DRIVEEXAMPLE

    Ifweconsiderafamiliarproblemofhumancontroldrivingacar.

    Thedriveristhereal-timecontroller,thecaristhecontrolledprocess,andtheothercars

    togetherwiththeroadconditionsmakeuptheoperatingenvironment.

    Wehavetwotypesofrealtimesystem:

    1. Soft real time system.

  • 7/27/2019 DCAP608_real Time System

    10/237

    Real Time Systems

    4 LOVELY PROFESSIONAL UNIVERSITY

    Notes 2. Hard real time system.

    1. Hard real time system: The requirement that all hard timing constraints must be validated

    invariablyplacesmanyrestrictionsonthedesignandimplementationofhardreal-time

    applicationsaswellasthearchitecturesofhardwareandsystemsoftwareusedtosupportthem.

    2. Soft real time system: A system in which jobs have soft deadlines is a soft-real system.

    Thedeveloperofarealtimesystemissurelyrequiredtoproverigorouslythatthesystem

    surelymeetsitsrealtimeperformanceobjective.

    Example:Onlinetransactionsystem,telephoneswitchesaswellaselectronicgames.

    Issues of Real Time System

    Arealtimecomputermustbemuchmorereliablethanitsindividualhardwareandsoftware

    component.Itmustbecapableofworkinginharshenvironments.

    For example:Taketaskscheduling.Realtimecomputersystemsdifferfromtheirgeneral-purpose

    counterpartsintwoimportantways.Firstlytheyaremuchmorespecicintheirapplications,

    andsecond,theconsequencesoftheirfailureallmoredrastic.

    Architecture Issues:

    (a) Processor architecture:Forreasonsofeconomy,off-the-shelfprocessorsarepreferred,real

    timedesignsseldomdesigntheirownprocessor,forthisreason,wedonottreatprocessor

    architectural.

    (b) Network architecture:Tomakesystemsreliableprovidesufcientprocessingcapacity,

    mostrealtimesystemsaremultipleprocessormachine.

    (c) Architecture for clock synchronization: In order to facilitate the interaction between the

    multipleunitsofarealtimesystem,theclocksofthisunitmustbesynchronizedandtightly.

    (d) Fault-tolerance and reliability evaluation:Peoplecandiewhenrealtimesystemfails.Such

    systems must therefore be legally fault-tolerant.

    Operating System Issues

    (a) Task assignment and scheduling: The scheduling of tasks ensures that real time deadlines

    aremet.Itiscentraltothemissionofareal-timeoperatingsystem.

    (b) Communication protocols:Itisimportanttohaveinterredprocessorcommunicationthat

    haspredictabledelaysandiscontrollable.

    (c) Failure management and recovery:Whenaprocessororsoftwaremodulefails,thesystem

    must limit such failure and recover from it.

    (d) Clock synchronization algorithm:Wementionedhardwaresynchronizationarchitecturebuiltoutofphaselockedlocks.

    Other Issues

    (a) Programming languages: Real times engineers need much greater control our timing and

    usedtointerfacetospecialpurposedevice.

    (b) Data bases:Therearemanyrealtimedata-baseapplications,suchasthe stockmarket,

    airline,reservationsandarticial,intelligence.

    (c) Performance measures:Commonlyusedperformancemeasuressuchasconventional

    reliabilityandthroughputareuselessforrealtimesystems.

  • 7/27/2019 DCAP608_real Time System

    11/237

    Unit 1: Concept of Real Times System

    LOVELY PROFESSIONAL UNIVERSITY 5

    NotesTypes of Task Classes of Real Time System

    Therearevetypesoftaskclasses:

    1. Periodic task:Therearemanytasksinrealtimesystemsthataredonerepetitively.For

    exampleonemaywishtomonitorthespeedaltitudeandattitudeofanaircraftevery100ms.Thissensorinformationwillbeusedbyperiodictasksthatcontrolandcontrolsurfacesof

    theaircraft(e.g.,theailerons,elevator,andrudderandenginethrusts),inordertomaintain

    stabilityandotherdesiredcharacteristics.Theperiodicityofthesetasksisknowntothe

    designer,andmanytaskscanbepre-scheduled.

    2. A periodic task:Therearemanyothertasksthatareaperiodic,thatoccuronlyoccasionally.

    Forinstance,whenthepilotwishestoexecuteaturnalargenumbersubtasks.Associated

    withthatactionareselfoffaperiodictaskscannotbepredicatedandsufcientcompleting

    powermustbeheldinreservetoexecutetheminatimelyfashion.Periodictaskswith

    boundedimperativaltimearecalledsporadictasks.

    3. Critical tasks:Criticaltasksarethatwhosetimelyexecutioniscritical;ifdeadlinesaremissed

    catastrophesoccur.Exampleincludeslifesupportsystemsandtheactabilitycontrolofair

    craft.Criticaltasksareoftenexecutedatahigherfrequencythanisabsolutelynecessary.

    4. Non critical tasks:Noncriticaltasksarerealtimestasks,thenameimpliesnotcriticalto

    theapplication.Howevertheydodealwithtimevaryingdataandhencetheyuselessif

    notcompletedwithinadeadline,thegoalinschedulingthesetasksisthesetomaximize

    thepercentageofjobssuccessfullyexecutedwithintheirdeadlines.

    Theanti-lockbrakesonacarareasimpleexampleofareal-timecomputing

    system the real-time constraint in this system is the time in which the brakes

    mustbereleasedtopreventthewheelfromlocking.

    Structure of a Real System

    Thestateofthecontrolledprocessandoftheoperatingenvironment(e.g.,pressure,temperature,

    speedandattitude)isacquiredbysensors,whichprovideinputtothecontroller,therealtime

    computer.Thereisaxedsetofapplicationtasksorjobs,thejoblist.

    Thesoftwareforthesetasksispreloadedintothecomputer.Ifthecomputerhasamainmemory,

    then the entire software is loaded into that.

    Figure 1.2: Structure of Real Time System

    ControlledSensors Job list Clock

    Trigger

    generator

    ExecutionActuators

    Display Operator

    process

    Trigger generator

    TheTriggergeneratorisarepresentationatthemechanismusedtotriggertheexecution

    ofindividualjobs.Itisnotreallyaseparatehardwareunit,typicallyitispartoftheexecutive

    softwaremanyofthejobsareperiodici.e.theyexecuteregularly.Thescheduleforthesejobscan

    beobtainedofineandloadedasalookuptabletousebythescheduler.

  • 7/27/2019 DCAP608_real Time System

    12/237

    Real Time Systems

    6 LOVELY PROFESSIONAL UNIVERSITY

    Notes

    Areal-timedeadlinemustbemet,regardlessofsystemload.

    1.2 Hard Real Time Systems

    A hardreal-timesystemguaranteesthatcriticaltaskscompleteontime.Thisgoalrequiresthatall

    delays in the system be bounded from the retrieval of the stored data to the time that it takes the

    operatingsystemtonishanyrequestmadeofitotherwisethesystemwillbecrashondeadline

    point(afterdelayingthispointthesystemwillcrash)asshowningure1.2.

    Realtimeapplicationscanbeclassiedaseitherhardorsoftrealtime.Hardrealtimeapplications

    requirearesponsetoeventswithinapredeterminedamountoftimefortheapplicationtofunction

    properly.Ifahardrealtimeapplicationfailstomeetspecieddeadlines,theapplicationfails.

    While many hard realtimeapplications requirehigh-speedresponses,the granularityofthe

    timingisnotthecentralissueinahardrealtimeapplication.

    Anexampleofa hardrealtimeapplicationis amissileguidancecontrolsystemwherealate

    responsetoaneededcorrectionleadstodisaster.

    Figure 1.3: Deadline Point in Hard Real Time System

    Cost

    Triggeringevent

    Deadline

    Time

    Ahardreal-timesystem(alsoknownasanimmediatereal-timesystem)ishardwareorsoftware

    thatmustoperatewithintheconnesofastringentdeadline.Theapplicationmaybeconsidered

    tohavefailedifitdoesnotcompleteitsfunctionwithintheallottedtimespan.Examplesofhard

    real-timesystemsincludecomponentsofpacemakers,anti-lockbrakesandaircraftcontrolsystems.

    Anoverruninresponsetimeleadstopotentiallossoflifeand/orbignancialdamage.

    Manyofthesesystemsareconsideredtobesafetycritical.

    Sometimestheyareonlymissioningoncritical,withthemissionbeingveryexpensive.

    Ingeneralthereisacostfunctionassociatedwiththesystem.

    Ahardreal-timesystemisonewhosesequencingtimelinessfactors(therealsomaybenon-

    timelinessfactors)areoptimalityisthebinarycasethatmeetingallharddeadlinesisoptimalandotherwiseissuboptimal(insomesystem-,application-,orsituation-specicway)predictability

    ofoptimalityisdeterministic.

    Thesearetheonlyhardreal-timesequencingtimelinessfactors,andahardreal-timesystemhas

    only these timeliness factors in its sequencing criterion. In the sequencing timeliness criterion

    2-dimensionalspaceof optimalityand predictabilityof optimality,hardreal-timeis atthe

    maximumoptimality/maximumpredictabilitycornerpoint;thetwofactorsarenottradedoff.

    Thisdenitioncorrespondstotheconsensuswithinthereal-timecomputingresearchcommunity

    thathardreal-timemeansallharddeadlinesarealwaysmet.(Thereal-timecomputingpractitioner

    (user,vendor)communityhasnoconsensusonthemeaningsofhardreal-timeandsoftreal-

    time,theyusethesetermsinmanydifferentill-denedways.)

  • 7/27/2019 DCAP608_real Time System

    13/237

    Unit 1: Concept of Real Times System

    LOVELY PROFESSIONAL UNIVERSITY 7

    NotesHardreal-timesystemstypicallyariseasfollows:

    1. Eitheralltheexecutionentitieshavingharddeadlinesaregatheredtogethertoformahard

    real-timesystem(usuallyafrontendsubsystematthedevicelevel)pairedwithasoft

    real-time,or(usually)non-real-time,backendsystem(forhumaninterface,database,etc.),because:

    Thesoft/non-real-timesystemisagivenandcannotsupportharddeadlines.

    Orthesystemdesigners/implementersdonotknowhowtoaccommodatemixedtime

    constraints in a single system.

    2. Orallthetimeconstraintsarearticiallyforcedtobeharddeadlinesbecausethesystem,

    oritsdesigners/implementers/users,cannotdealwithanyotherkindoftimeconstraints.

    Partitioningacomputingsystemintoa hardreal-timefrontendanda non-real-timeback

    endcanbeanaturalandeffectiveapproachinsomecases.Butinmanyothercasesitlimitsthe

    effectivenessoffrontendcomputing,byrestrictingittoharddeadlinesandthehardreal-time

    sequencingtimelinesfactors,orofbackendcomputingbypreventingitfromemployingtime-constraint driven resource management.

    1.3 Soft Real Time Systems

    A soft real-time system isonethatisnotthehardreal-timespecialcase,andisthusthegeneralcase.

    Thesequencingtimelinessoptimalityfactormaybeanythingexamplesoffactorsusedverywidely

    (outsidethetraditionalreal-timecomputingcommunity)areminimizethenumberofmissed

    deadlines,andminimizetotaltardiness.Thepredictabilityofoptimalityisnon-deterministic,

    andisoftenmodelledstochastically.Verycommonexamples(outsidethetraditionalreal-time

    computingcommunity)ofsequencingtimelinesscriteriaintermsofbothfactorsareminimize

    theexpectednumberofmisseddeadlines,andminimizethemeantotaltardiness.

    Deadlineoverrunsaretolerable,butnotdesired.

    Therearenocatastrophicconsequencesofmissingoneormoredeadlines.

    Thereisacostassociatedtooverrunning,butthiscostmaybeabstract.

    OftenconnectedtoQuality-of-Service(QoS).

    Figure 1.4: Deadline Point in Soft Real Time System

    Example costfunction

    Triggeringevent

    CostDeadline

    Time

    Asoftrealtimesystemwhereacriticalreal-timetaskgetspriorityoverothertasksandretains

    thatpriorityuntilitcompletes.Softrealtimeapplicationsdonotfailifadeadlineismissed.Somesoftrealtimeapplicationscanprocesslargeamountsofdataorrequireaveryfastresponsetime,butthekeyissueiswhetherornotmeetingtimingconstraintsisaconditionforsuccess.Anexampleofasoftrealtimeapplicationisanairlinereservationsystemwhereanoccasionaldelayistolerable,butunwanted.

    Softreal-timeistheentirespaceexceptforthehardreal-timecornerpoint.Asystemcanbeconsidered to be a hard real-time one to the degree that it has hard deadlines and a sequencing

    timeliness factor that includes always meeting all the hard deadlines.

  • 7/27/2019 DCAP608_real Time System

    14/237

    Real Time Systems

    8 LOVELY PROFESSIONAL UNIVERSITY

    Notes Somesoftreal-timesystemsarenon-stochasticallynon-deterministic.Theyhavepropertiesthatare

    soasynchronous-inthesenseofintermittent,irregular,eitherinterdependentorcompetitivethat

    stochasticmodelsofpredictabilityforthemareeitherunknownorcomputationallyintractable.

    Reasoningaboutthesequencetimelinessofsuchsystemsistypicallyperformedusingsimulation

    modelsorextensional(rule-based)andothermodelsfromeldssuchasarticialintelligence,

    decisiontheory,etc.

    Preparealistofvelatestrealtimeoperatingsystem.

    Hardreal-timesystemsmusthaveatleastsomeactionswithharddeadlines.Buttheconverseis

    not true soft real-time systems may have actions with hard deadlines. Those systems are soft real-

    timebecausetheydonotemploythehardreal-timesequencingtimelinesscriterion,theyemploy

    softreal-timeonessuchasminimizetheexpectednumberofmisseddeadlines,regardlessof

    whether the deadlines are hard or soft.

    Itis clearthatin thetechnicalsense definedhere(as opposedto popularmiss usageby

    practitioners),softreal-timesystemsareconsiderablymoredifculttocreatethanarehardreal-

    time ones.

    Hardreal-timeandsoftreal-timeapplyonlytoasystem,becausetheir

    denitionsarebasedonsequencing.Inthissense,asystemisanyresource

    management facility that includes sequencing.

    1.4 Hard Versus Soft Real Time System

    Ahardreal-timesystemguaranteesthatcriticaltaskscompleteontime.Thisgoalrequiresthat

    all delays in the system be bounded from the retrieval of the stored data to the time that it takestheoperatingsystemtonishanyrequestmadeofit.

    Acriticaltaskobtainsapriorityoverothertasksandmaintainingthatpriorityuntilthecompletion

    ofthetask.Thisisperformedbyasoftrealtimesystem.Thesystemkerneldelaysneedtobe

    bounded as in the case of hard real time system.

    Hardrealtimetasksmustcompletetheirprocessingbyaparticulardeadline.Normally

    somethingbadwillhappenifthedeadlineismissed.

    Softrealtimetaskshaveapreferredcompletiontime.Normallymissingthedeadlineisnotfatal.

    Drawadiagramforsoftwarerealtimesystemintheairticketing.

    Table1.1showsthemajordifferencesbetweenhardandsoftreal-timesystems.Theresponsetime

    requirements of hard real-time systems are in the order of milliseconds or less and can result in

    acatastropheifnotmet.Incontrast,theresponsetimerequirementsofsoftreal-timesystems

    arehigherandnotverystringent.Inasoftreal-timesystem,adegradedoperationinararely

    occurringpeakloadcanbetolerated.Ahardreal-timesystemmustremainsynchronouswith

    the state of the environment in all cases. On the other hand soft real-time systems will slow down

    theirresponsetimeiftheloadisveryhigh.Hardreal-timesystemsareoftensafetycritical.Hard

    real-timesystemshavesmalldatalesandreal-timedatabases.Temporalaccuracyisoftenthe

    concernhere.Softreal-timesystemsforexample,on-linereservationsystemshavelargerdatabases

    andrequirelong-termintegrityofreal-timesystems.Ifanerroroccursinasoftreal-timesystem,

  • 7/27/2019 DCAP608_real Time System

    15/237

    Unit 1: Concept of Real Times System

    LOVELY PROFESSIONAL UNIVERSITY 9

    Notes

    thecomputationisrolledbacktoapreviouslyestablishedcheckpointtoinitiatearecoveryaction.

    Inhardreal-timesystems,roll-back/recoveryisoflimiteduse.

    A real-time system is one whose correctness is based on both the correctness

    oftheoutputsandtheirtimeliness.

    Inahardreal-timesystem,thepeak-loadperformancemustbepredictable

    andshouldnotviolatethepredeneddeadlines.

    Table 1.1: Differences Between Hard and Soft Real-time Systems

    Characteristic Hard real-time Soft real-time

    Response Time Hard-required Soft-desired

    Peak-load performance Predictable Degraded

    Control of pace EnvironmentComputer

    Safety OftencriticalNon-critical

    Size of data les Small/medium Large

    Redundacy type Active Checkpoint-recovery

    Data integrity Short-term Long-term

    Error detection Autonomous Userassisted

    Correct Development of Real-time Embedded Systems

    in UML

    OMEGAwilldevelopamethodologyandtoolsforthedevelopmentofreal-timeandembeddedsystemsusingUML,basedonacleansemanticsofthedifferent

    architecturalviewpointsandtheirrelations.Theaimoftheprojectistoincreasethe

    efciencyandcompetitivenessoftheEuropeansoftwareindustrybyprovidingtoolsimproving

    thequalityofsoftwarewhilereducingtheexpenseofthevalidationphase.TheOMEGA

    approachtosoftwarequalityistouseUMLforthedescriptionofauniquereferencemodel,

    fromwhicharederivedsemanticallyrelatedmodelsforfunctional,validation,performance

    analysis,aswellasimplementations;allevolutionsarereportedinthereferencemodelfor

    trackingofitsinuence.Asemanticallysoundcomponentbaseddevelopmentplaysan

    importantrole,whichmakessurethatinterfacesaresufcienttoguaranteetherequirements.

    Objectives

    OMEGAaimsatthedenitionofadevelopmentmethodologyinUMLforembeddedand

    real-timesystemsbasedonformaltechniquesandusedtoimprovecommerciallyavailableUMLtools.ForthispurposewewillIdentifyreasonableandeffectivesubsetsofUMLfor

    real-time,aswellasnecessaryextensions.Provideformalfoundations,methodsandtools

    forcompositionalvericationofreal-timesystemswithinUML.Constructadevelopment

    methodologybasedontheUMLmodellingandspecicationcapabilitiesandtheverication

    methodsandtoolsdevelopedintheproject.Applyindustrialcasestudiesforevaluatingthe

    proposedmethodologyandvericationtools.Workdescription:

    Toachieveouraim,wewilldevelopresultsinthefollowinginterdependentdirections:

    1. Modelling and Specication Language: WeselectasmallsubsetofUMLnotations

    thatallowthedesignofreactiveandreal-timesystems.Ifneeded,wealsopropose

    smallextensions.Theresultinglanguagecontainsnotationstomodelthesystemunder

    development includingboth functional andnon-functionalaspects,and specifythe

    requirements to be met by the system. Contd...

  • 7/27/2019 DCAP608_real Time System

    16/237

    Real Time Systems

    10 LOVELY PROFESSIONAL UNIVERSITY

    Notes 2. Verification and Synthesis:Wewilladaptandextendexistingformalverification

    technologiestoUML,identifythenewneedsinvericationtechniquesraisedbythe

    powerfulstructuringfeaturesofUMLanddevelopcompositionalvericationmethods,

    allowingderivingpropertiesofsystemsfrompropertiesofcomponents.Thetechniques

    areconnectedtotwoindustrialCASEtools,leadingtotwovericationtool-sets.Wewill

    also developtoolsthatin certaincasesdirectlysynthesizesystemssatisfyingrequired

    properties.

    3. Development Methodology:Wewilldevelopamethodology,providingguidelinesabout

    theuseandthecombinationofthedifferentnotations.Inparticular,themethodologywill

    bebasedonrenementandpropertypreservationrules,relatingthedifferentabstraction

    levels.

    4. Technology Transfer:Wewillshowhowthedevelopedresults-theory,methodsand

    tools-canbeappliedtoreal-timesystemsdevelopmentbyusingappropriateextensions

    ofcommerciallyavailabletools.Ourapproachwillbeevaluatedandadaptedonthebasis

    of four industrial case studies.

    Milestones

    1. DenitionofaUMLkernelmodel(KM):aminimalsubsetofUMLforthedevelopment

    ofreal-timeandembeddedsystems;

    2. SemanticfoundationsoftheKM;

    3. Adaptionofexistingmodel-checkingtechniquestotheKMforcomponentverication;

    4. Twointegratedtool-setsfor system verication based oncompositionalmethodsand

    synthesis;

    5. Adevelopmentmethodologybasedonsemanticpreservingnotionsofrenement;

    Questions:

    1. ExplaintheobjectivesofdevelopmentmethodologyinUMLforembeddedandreal-time

    systems.

    2. Discussinbriefreal-timeembeddedsystemsinUML.

    Self Assessment

    Choose the correct answer:

    6. Hardreal-timesystemishardwareorsoftwarethatmustoperatewithintheconnesofa

    stringent timeline.

    (a) True (b) False

    7. Operatingsystemmusthaveaknownmaximumtimeforeachoftheoperationsthatit

    performs.

    (a) True (b) False

    8. Ahardreal-timesystemnotguaranteedthatcriticaltaskscompleteontime.

    (a) True (b) False

    9. Predictabilityistheconditionof.hastoreacttoallpossibleeventsinapredictable

    way.

    (a) typeofsoftrealtimesystem (b) typeofsoftrealtimesystem

    (c) real-timesystem (d) noneofthese

    10. Simultaneityorsimultaneousprocessingmorethanoneeventmayhappensimultaneously,

    all deadlines should be met.

    (a) True (b) False

  • 7/27/2019 DCAP608_real Time System

    17/237

    Unit 1: Concept of Real Times System

    LOVELY PROFESSIONAL UNIVERSITY 11

    Notes1.5 Summary

    Realtimetermisusedtodescribeanumberofdifferentcomputerfeaturesitrefertoevents

    simulatedbyacomputeratthesamespeedthattheywouldoccurinreallife.

    Arealtimeapplicationisanapplicationwherethecorrectnessoftheapplicationdepends

    onthetimelinesandpredictabilityoftheapplicationaswellastheresultsofcomputations.

    Areal-timesystemisanyinformationprocessingsystemwhichhastorespondtoexternally

    generatedinputstimuliwithinaniteandspeciedperiod.

    Ahard real-time system isone whosesequencingtimeliness factorsare optimality is

    thebinarycasethatmeetingallharddeadlinesisoptimalandotherwiseissuboptimal

    predictabilityofoptimalityisdeterministic.

    Ahardreal-timesystemknownasanimmediatereal-timesystem.

    1.6 Keywords

    Deadline point:Thisisapointinrealtimesystemafterdelayingthispointthesystemwillcrash.

    Dependability or trustworthiness: It is necessary condition that the real-time system environment

    can rely on it.

    Hard real-time system:Itishardwareorsoftwarethatmustoperatewithintheconnesofa

    stringent deadline.

    Immediate real-time system:Itishardwareorsoftwarethatmustoperatewithintheconnesof

    a stringent deadline.

    Predictability: Itis theconditionofreal-time system has toreact toallpossible events ina

    predictableway.

    Real time:Thetermisusedtodescribeanumberofdifferentcomputerfeatures.Forexample,

    real-timeoperatingsystemsaresystemsthatrespondtoinputimmediately.

    Real time system:Itisareal-timesystemwhenitcansupporttheexecutionofapplicationswith

    timeconstraintsonthatexecution.

    Simultaneity or simultaneous processing:Thisismorethanoneeventmayhappensimultaneously,

    all deadlines should be met this is a condition of real time system.

    Soft real-time system: It can be a vending machine rising cost for lateness of results as it will

    takelongertotreatacustomerwhentheperformanceofthevendingmachineisdegrading,less

    customerspayatthismachinewhichresultsinlessprotsfortheshopowner.

    Trigger generator:Itisarepresentationatthemechanismusedtotriggertheexecutionofindividualjobs.

    Timeliness:Itisaconditionofrealtimesystemthatmeetdeadlinesitisrequiredthattheapplication

    hastonishcertaintaskswithinthetimeboundariesithastorespect.

    1. Designatimegraphforreal-timesystemswithtimingconstraints.

    2. Prepareaprocessdiagramforperiodictask.

  • 7/27/2019 DCAP608_real Time System

    18/237

    Real Time Systems

    12 LOVELY PROFESSIONAL UNIVERSITY

    Notes 1.7 Review Questions

    1. What do you understand by real time?

    2. Explaintheimportanceofrealtimesystemandstructureofit.

    3. Describetheconceptofrealtimeoperatingsystem.

    4. Discussinbriefhardandsoftrealtimesystem.

    5. Discussintypesoftaskinrealtimesystem.

    6. Differentiatebetweenhardandsoftrealtimesystem.

    7. Whatisdeadlinepointinrealtimesystem?

    8. Denetimelineinrealtimesystem.

    9. Whichtypeofrealtimesystemuseinaircraft?

    10. Denetimingconstraints.Andwhatisutilityofitinbothrealtimesystems?

    Answers to Self Assessment

    1. (a) 2. (a) 3. (b) 4. (d) 5. (a)

    6. (b) 7. (a) 8. (b) 9. (c) 10. (a)

    1.8 Further Reading

    Alan, C. Shaw, RTS and Software,byJohnWileyandSons,NewYork,2001.

    http://www.ece.cmu.edu/~koopman/des_s99/real_time/

  • 7/27/2019 DCAP608_real Time System

    19/237

    LOVELY PROFESSIONAL UNIVERSITY 13

    NotesUnit 2: Introduction to Real Time Applications

    CONTENTS

    Objectives

    Introduction

    2.1 DigitalControl

    2.1.1 SampledDataSystems

    2.1.2 MoreComplexControl-lawComputations

    2.2 High-LevelControls

    2.2.1 ExamplesofControlHierarchy

    2.2.2 GuidanceandControl

    2.2.3 Real-timeCommandandControl

    2.3 SignalProcessing

    2.3.1 ProcessingBandwidthDemands

    2.3.2 Radar System

    2.4 OtherReal-timeApplications

    2.4.1 Real-timeDatabases

    2.4.2 MultimediaApplications

    2.5 Summary

    2.6 Keywords

    2.7 ReviewQuestions

    2.8 Further Reading

    Objectives

    After studying this unit, you will be able to:

    Discussaboutthedigitalcontrolsinrealtimesystem

    Explainthehigh-levelcontrols

    Discussthesignalprocessing

    Describetheotherreal-timeapplications

    Introduction

    Thereal-time(computing)systemestimatesfromthesensorreadingsthecurrentstateofthe

    plantandcomputesacontroloutputbasedonthedifferencebetweenthecurrentstateandthe

    desiredstate(calledreferenceinput).Wecallthiscomputationthecontrol-lawcomputation

    ofthecontroller.Theoutputthusgeneratedactivatestheactuators,whichbringtheplant

    closer to the desired state. One or more digital controllers at the lowest level directly control

    thephysicalplant.Outputofahigher-levelcontrollerisareferenceinputofoneormore

    lower-level controllers.

    2.1 Digital Control

    Many real-time systems are embedded in sensors and actuators and function as digital controllers.

    Figure2.1showssuchasystem.Thetermplantintheblockdiagramreferstoacontrolledsystem,

  • 7/27/2019 DCAP608_real Time System

    20/237

    Real Time Systems

    14 LOVELY PROFESSIONAL UNIVERSITY

    Notes forexample,anengine,abrake,anaircraft,apatient.Thestateoftheplantismonitoredbysensors

    and can be changed by actuators.

    2.1.1 Sampled Data Systems

    Longbeforedigitalcomputersbecamecost-effectiveandwidelyused,analogue(i.e.,continuous

    timeandcontinuous-state)controllerswereinuse,andtheirprincipleswerewellestablished.

    Consequently,acommonapproachtodesigningadigitalcontrolleristostartwithananalogue

    controller that has the desired behaviour. The analogue version is then transformed into a digital

    (i.e.,discrete-timeanddiscrete-state)version.Theresultantcontrollerisasampleddatasystem.It

    typicallysamples(i.e.,reads)anddigitizestheanaloguesensorreadingsperiodicallyandcarries

    outitscontrol-lawcomputationeveryperiod.Thesequenceofdigitaloutputsthusproducedis

    then converted back to an analogue form needed to activate the actuators.

    A Simple Example

    Asanexample,weconsiderananaloguesingle-input/single-outputPID(Proportional,Integral,

    andDerivative)controller.Thissimplekindofcontrolleriscommonlyusedinpractice.The

    analoguesensorreadingy(t)givesthemeasuredstateoftheplantattime t.Lete(t)=r(t)y(t)denote the difference between the desired state r(t)andthemeasuredstatey(t)attimet. The

    outputu(t)ofthecontrollerconsistsofthreeterms:atermthatisproportionaltoe(t),aterm

    thatisproportionaltotheintegralofe(t)andatermthatisproportionaltothederivativeofe(t).

    Figure 2.1: A Digital Controller

    Reference

    input

    r(t)

    rk

    yk

    ukD/A

    Control-law

    computation

    Sensor Plant Actuator

    y(t) u(t)

    Controller

    A/D

    A/D

    Inthesampleddataversion,theinputstothecontrol-lawcomputationarethesampledvalues yk

    and rk,fork=0,1,2,...,whichanalogue-to-digitalconvertersproducebysamplinganddigitizing

    y(t)andr(t)periodicallyeveryTunits of time. The ek=rkyk is the kthsamplevalueofe(t).There

    aremanywaystodiscretizethederivativeandintegralof e(t).Forexample,wecanapproximate

    the derivative of e(t)for(k1)T

  • 7/27/2019 DCAP608_real Time System

    21/237

    Unit 2: Introduction to Real Time Applications

    LOVELY PROFESSIONAL UNIVERSITY 15

    Notesdoanalogue-to-digitalconversiontogety;computecontroloutputu;

    outputuanddodigital-to-analogueconversion;

    enddo;

    Here,weassumethatthesystemprovidesatimer.Oncesetbytheprogram,thetimergenerates

    aninterrupteveryTunits of time until its setting is cancelled.

    Selection of Sampling Period

    The length Tof time between any two consecutive instants at which y(t)andr(t)aresampled

    is called the sampling period. The Tis a key design choice. The behaviour of the resultant digital

    controllercriticallydependsonthisparameter.Ideallywewantthesampleddataversiontobehave

    liketheanalogueversion.Thiscanbedonebymakingthesamplingperiodsmall.However,a

    smallsamplingperiodmeansmorefrequentcontrol-lawcomputationandhigherprocessor-time

    demand.WewantasamplingperiodTthatachievesagoodcompromise.

    Weneedtoconsidertwofactors.Therstistheperceivedresponsivenessoftheoverall,system

    (i.e.,theplantandthecontroller).Oftentimes,thesystemisoperatedbyaperson(e.g.,adriver

    orapilot).Theoperatormayissueacommandatanytime,sayat t. The consequent change in

    thereferenceinputisreadandreactedtobythedigitalcontrolleratthenextsamplinginstant.

    This instant can be as late as t + T.Thus,samplingintroducesadelayinthesystemresponse.The

    operatorwillfeelthesystemsluggishwhenthedelayexceedsatenthofasecond.Therefore,the

    samplingperiodofanymanualinputshouldbeunderthislimit.

    Thesecondfactoristhedynamicbehaviouroftheplant.Wewanttokeeptheoscillationinits

    responsesmallandthesystemundercontrol.Theplantinthisexampleisthearmofadisk.The

    controllerisdesignedtomovethearmtotheselectedtrackeachtimewhenthereferenceinput

    changes.Ateachchange,thereferenceinput r(t)isastepfunctionfromtheinitialpositiontothe

    nalposition.InFigure2.2,thesepositionsarerepresentedby0and1,respectively,andthetime

    originistheinstantwhenthestepinr(t)occurs.ThedashedlinesinFigure2.2(a)

    Figure 2.2: Effects of Sampling Period

  • 7/27/2019 DCAP608_real Time System

    22/237

    Real Time Systems

    16 LOVELY PROFESSIONAL UNIVERSITY

    Notes

    givetheoutputu(t)of theanaloguecontrollerandtheobservedpositiony(t)ofthearmasa

    functionoftime.Thesolidlinesintheloweranduppergraphsgive,respectively,theanalogue

    controlsignalconstructedfromthedigitaloutputsofthecontrollerandtheresultantobserved

    positiony(t)ofthearm.Atthesamplingrateshownhere,theanalogueanddigitalversionsare

    essentiallythe same.Thesolidlinesin Figure2.2(b)givethebehaviourofthe digitalversion

    whenthesamplingperiodisincreasedby2.5times.Theoscillatorymotionofthearmismore

    pronouncedbutremainssmallenoughtobeacceptable.However,whenthesamplingperiodis

    increasedbyvetimes,asshowninFigure2.2(c),thearmrequireslargerandlargercontroltostayinthedesiredposition;whenthisoccurs,thesystemissaidtohavebecomeunstable.

    Ingeneral,thefasteraplantcanandmustrespondtochangesinthereferenceinput,thefaster

    theinputtoitsactuatorvaries,andtheshorterthesamplingperiodshouldbe.Wecanmeasure

    theresponsivenessoftheoverallsystembyitsrise time R. This term refers to the amount of time

    thattheplanttakestoreachsomesmallneighbourhoodaroundthenalstateinresponsetoa

    stepchangeinthereferenceinput.IntheexampleinFigure2.2,asmallneighbourhoodofthe

    nalstatemeansthevaluesofy(t)thatarewithin5%ofthenalvalue.Hence,therisetimeof

    thatsystemisapproximatelyequalto2.5.

    A good rule of thumb is the ratio R/T of rise time to sampling period is from 10 to 20 .Inotherwords,

    thereare1020samplingperiodswithintherisetime.AsamplingperiodofR/10shouldgivean

    acceptablysmoothresponse.However,ashortersamplingperiod(andhenceafastersamplingrate)islikelytoreducetheoscillationinthesystemresponseevenfurther.Forexample,the

    samplingperiodusedtoobtainFigure2.2(b)isaroundR/10whilethesamplingperiodusedto

    obtainFigure2.2(a)isaroundR/20.

    Theaboveruleisalsocommonlystatedintermsofthebandwidth, w,ofthesystem.Thebandwidthoftheoverallsystemisapproximatelyequalto1/2RHz.Sothesamplingrate(i.e.,theinverseof

    samplingperiod)recommendedaboveis2040timesthesystembandwidthw. The theoreticallowerlimitofsamplingrateisdictatedby Nyquist sampling theorem. The theorem says that any

    time-continuous signal of bandwidth w can be reproduced faithfully from its sampled values if and only ifthe sampling rate is 2w or higher.Weseethattherecommendedsamplingrateforsimplecontrollersissignicantlyhigherthanthislowerbound.Thehighsamplingratemakesitpossibletokeep

    thecontrolinputsmallandthecontrol-lawcomputationanddigital-to-analogueconversionofthecontrollersimple.

    Multirate Systems

    Aplanttypicallyhasmorethanone degreeoffreedom.Itsstateisdenedbymultiplestate

    variables(e.g.,therotationspeed,temperature,etc.ofanengineorthetensionandpositionofa

    videotape).Therefore,itismonitoredbymultiplesensorsandcontrolledbymultipleactuators.

    Wecanthinkofamultivariate(i.e.,multi-input/multi-output)controllerforsuchaplantasa

    systemofsingle-outputcontrollers.

    Becausedifferentstatevariablesmayhavedifferentdynamics,thesamplingperiodsrequiredto

    achievesmoothresponsesfromtheperspectiveofdifferentstatevariablesmaybedifferent.[For

    example,becausetherotationspeedsofanenginechangesfasterthanitstemperature,therequired

  • 7/27/2019 DCAP608_real Time System

    23/237

    Unit 2: Introduction to Real Time Applications

    LOVELY PROFESSIONAL UNIVERSITY 17

    NotessamplingrateforRPM(RotationperMinute)controlishigherthanthatforthetemperature

    control.]Ofcourse,wecanusethehighestofallrequiredsamplingrates.Thischoicesimplies

    thecontrollersoftwaresinceallcontrollawsarecomputedatthesamerepetitionrate.However,

    somecontrol-lawcomputationsaredonemorefrequentlythannecessary;someprocessortime

    iswasted.Topreventthiswaste,multivariatedigitalcontrollersusuallyusemultipleratesand

    are therefore called multirate systems.

    Oftentimes,thesamplingperiodsusedinamultiratesystemarerelatedinaharmonicway,that

    is,eachlongersamplingperiodisanintegermultipleofeveryshorterperiod.Toexplainthe

    control-theoreticalreasonforthischoice,wenotethatsomedegreeofcouplingamongindividual

    single-outputcontrollersin asystemis inevitable.Consequently,the samplingperiodsof the

    controllerscannotbeselectedindependently.Amethodforthedesignandanalysisofmultirate

    systemsisthesuccessiveloopclosuremethod.Accordingtothismethod,thedesignerbeginsby

    selectingthesamplingperiodofthecontrollerthatshouldhavethefastestsamplingrateamong

    allthecontrollers.Inthisselection,thecontrollerisassumedtobeindependentoftheothersin

    thesystem.Afteradigitalversionisdesigned,itisconvertedbackintoananalogueform.The

    analoguemodelisthenintegratedwiththeslowerportionoftheplantandistreatedasapart

    oftheplant.Thisstepisthenrepeatedforthecontrollerthatshouldhavethefastestsampling

    rateamongthecontrollerswhosesamplingperiodsremaintobeselected.Theiterationprocess

    continuesuntiltheslowestdigitalcontrollerisdesigned.Eachstepusesthemodelobtainedduring

    thepreviousstepastheplant.Whenthechosensamplingperiodsareharmonic,theanalogue

    modelsofthedigitalcontrollersusedinthisiterativeprocessareexact.Theonlyapproximation

    arisesfromtheassumptionmadeintherststepthatthefastestcontrollerisindependent,and

    theerrorduetothisapproximationcanbe-correctedtosomeextentbyincorporatingtheeffectof

    theslowercontrollersintheplantmodelandthenrepeatingtheentireiterativedesignprocess.

    An Example of Software Control Structures

    Asanexample,Figure2.3showsthesoftwarestructureofaightcontroller.Theplantisa

    helicopter.Ithasthreevelocitycomponents;together,theyarecalledcollectiveinthegure.It

    alsohasthreerotational(angular)velocities,referredtoasroll,pitch,andyaw.Thesystemusesthreesamplingrates:180,90and30Hz.Afterinitialization,thesystemexecutesadoloopatthe

    rateofoneiterationevery1/180second;inthegureacyclemeansa1/180-secondcycle,and

    thetermcomputationmeansacontrol-lawcomputation.

    Specically,atthestartofeach1/180-secondcycle,thecontrollerrstchecksitsownhealthand

    reconguresitselfifitdetectsanyfailure.Itthendoeseitheroneofthethreeavionicstasksor

    computesoneofthe30-Hzcontrollaws.Wenotethatthepilotscommand(i.e.,keyboardinput)

    ischeckedevery1/30second.Atthissamplingrate,thepilotshouldnotperceivetheadditional

    delayintroducedby sampling.Themovementofthe aircraftalongeachof thecoordinatesis

    monitoredandcontrolledbyaninnerandfasterloopandanouterandslowerloop.Theoutput

    producedbytheouterloopisthereferenceinputtotheinnerloop.Eachinnerloopalsousesthe

    dataproducedbytheavionicstasks.

    Figure 2.3: An Example: Software Control Structure of a Flight Controller

    Do the following in each 1/180-second cycle:

    Validatesensordataandselectdatasource;inthepresenceoffailures,recongurethesystem.

    Dothefollowing30-Hzavionicstasks,eachonceeverysixcycles:

    keyboardinputandmodeselection

    datanormalizationandcoordinatetransformation

    trackingreferenceupdate

    Dothefollowing30-Hzcomputations,eachonceeverysixcycles:

    controllawsoftheouterpitch-controlloop

  • 7/27/2019 DCAP608_real Time System

    24/237

    Real Time Systems

    18 LOVELY PROFESSIONAL UNIVERSITY

    Notes controllawsoftheouterroll-controlloop

    controllawsoftheouteryaw-andcollective-controlloop

    Doeachofthefollowing90-Hzcomputationsonceeverytwocycles,usingoutputsproducedby

    30-Hzcomputationsandavionicstasksasinput: controllawsoftheinnerpitch-controlloop

    controllawsoftheinnerroll-andcollective-controlloop

    Computethecontrollawsoftheinneryaw-controlloop,usingoutputsproducedby90-Hzcontrol

    lawcomputationsasinput.

    Outputcommands.

    Carryoutbuilt-in-test.

    Waituntilthebeginningofthenextcycle.

    Thismultiratecontrollercontrolsonlyightdynamics.Thecontrolsystemonboardanaircraftis

    considerablymorecomplexthanindicatedbythegure.Ittypicallycontainsmanyotherequally

    criticalsubsystems(e.g.,airinlet,fuel,hydraulic,brakesandanti-icecontrollers)andmanynotsocriticalsubsystems(e.g.,lightingandenvironmenttemperaturecontrollers).So,inadditiontothe

    ightcontrol-lawcomputations,thesystemalsocomputesthecontrollawsofthesesubsystems.

    Timing Characteristics

    Togeneralize fromthe aboveexample,wecan see that theworkloadgeneratedbyeach

    multivariate,multiratedigitalcontrollerconsistsofafewperiodiccontrol-lawcomputations.

    Theirperiodsrangefroma fewmillisecondstoa fewseconds.Acontrolsystemmaycontain

    numerousdigitalcontrollers,eachofwhichdealswithsomeattributeoftheplant.Togetherthey

    demandtensorhundredsofcontrollawsarecomputedperiodically,someofthemcontinuously

    andothersonlywhenrequestedbytheoperatororinreactiontosomeevents.Thecontrollaws

    ofeachmultiratecontrollermayhaveharmonicperiods.Theytypicallyusethedataproduced

    byeachotherasinputsandaresaidtobearategroup.Ontheotherhand,thereisnocontroltheoreticalreasontomakesamplingperiodsofdifferentrategroupsrelatedinaharmonicway.

    Eachcontrol-lawcomputationcanbeginshortlyafterthebeginningofeachsamplingperiodwhen

    themostrecentsensordatabecomeavailable.(Typically,thetimetakenbyananalogue-to-digital

    convertertoproducesampleddataandplacethedatainmemorydoesnotvaryfromperiodto

    periodandisverysmallcomparedwiththesamplingperiod.)Itisnaturaltowantthecomputation

    completeand,hence,thesensordataprocessedbeforethedatatakeninthenextperiodbecome

    available.Thisobjectiveismetwhentheresponsetimeofeachcontrol-lawcomputationnever

    exceedsthesamplingperiod.Theresponsetimeofthecomputationcanvaryfromperiodto

    period.Insomesystems,itis necessarytokeepthisvariationsmallsothatthedigitalcontrol

    outputsproducedbythecontrollerbecomeavailableattimeinstantsmoreregularlyspacedin

    time.Inthiscase,wemayimposeatimingjitterrequirementonthecontrol-lawcomputation:

    thevariationinitsresponsetimedoesnotexceedsomethreshold.

    Real-timecomputationsmaybefailediftheyarenotcompletedbeforetheir

    deadline,wheretheirdeadlineisrelativetoanevent.

    2.1.2 More Complex Control-law Computations

    ThesimplicityofaPIDorsimilardigitalcontrollerfollowsfromthreeassumptions.First,sensor

    data give accurate estimates of the state-variable values being monitored and controlled. This

    assumptionisnotvalidwhennoiseanddisturbancesinsideoroutsidetheplantpreventaccurate

    observationsofitsstate.Second,thesensordatagivethestateoftheplant.Ingeneral,sensors

    monitorsomeobservableattributesoftheplant.Thevaluesofthestatevariablesmustbecomputed

  • 7/27/2019 DCAP608_real Time System

    25/237

    Unit 2: Introduction to Real Time Applications

    LOVELY PROFESSIONAL UNIVERSITY 19

    Notesfromthemeasuredvalues(i.e.,digitizedsensorreadings).Third,alltheparametersrepresenting

    thedynamicsoftheplantareknown.Thisassumptionisnotvalidforsomeplants.(Anexample

    isaexiblerobotarm.Eventheparametersoftypicalmanipulatorsusedinautomatedfactories

    arenotknownaccurately.)

    Sincetheseassumptionsareoftennotvalid,youoftenseedigitalcontrollersimplementedas

    follows.

    settimertointerruptperiodicallywithperiodT;

    ateachclockinterrupt,do

    sampleanddigitizesensorreadingstogetmeasuredvalues;

    computecontroloutputfrommeasuredandstate-variablevalues;

    convertcontroloutputtoanalogueform;

    estimateandupdateplantparameters;

    computeandupdatestatevariables;

    enddo;

    Thelasttwostepsintheloopcanincreasetheprocessortimedemandofthecontrollersignicantly.

    Wenowgivetwoexampleswherethestateupdatestepisneeded.

    Deadbeat Control

    A discrete-time control scheme that has no continuous-time equivalence is deadbeat control. In

    responsetoastepchangeinthereferenceinput,adead-beatcontrollerbringstheplanttothe

    desiredstatebyexertingontheplantaxednumber(sayn)ofcontrolcommands.Acommand

    is generated every Tseconds.(Tisstillcalledasamplingperiod.)Hence,theplantreachesits

    desired state in nTsecond.

    Inprinciple,thecontrol-lawcomputationofadead-beatcontrollerisalsosimple.Theoutput

    producedbythecontrollerduringthekthsamplingperiodisgivenby

    uk = ( )r y xi ii

    k

    i ii

    k

    += =

    0 0

    [ThisexpressioncanalsobewritteninanincrementalformsimilartoEq.(2.1).]Again,theconstants

    a and bis are chosen at design time. xiisthevalueofthestatevariableinthesamplingperiod.Duringeachsamplingperiod,thecontrollermustcomputeanestimateofxk from measured values

    yi,fori < k.Inotherwords,thestateupdatestepintheabovedoloopisneeded.

    Kalman Filter

    Kalmanlteringisacommonlyusedmeanstoimprovetheaccuracyofmeasurementsandtoestimatemodelparametersinthepresenceofnoiseanduncertainty.Toillustrate,weconsidera

    simplemonitorsystemthattakesameasuredvalueykeverysamplingperiodk in order to estimate

    the value xkofastatevariable.Supposethatstartingfromtime0,thevalueofthisstatevariable

    is equal to a constant x.Becauseofnoise,themeasuredvalueyk is equal to x + ek,whereek is arandomvariablewhoseaveragevalueis0andstandarddeviationissk.TheKalmanlterstartswith the initial estimate x1 =ylandcomputesanewestimateseachsamplingperiod.Specically,

    for k>1,theltercomputestheestimate xk asfollows:

    xk = x K y xk k k k + 1 1( ) ...(2.2a)

  • 7/27/2019 DCAP608_real Time System

    26/237

    Real Time Systems

    20 LOVELY PROFESSIONAL UNIVERSITY

    Notes Inthisexpression,

    Kk =P

    P

    k

    k k2+

    ...(2.2b)

    is called the Kalman gain and Pk is the variance of the estimation error x x ; the latter is given by

    Pk = E x x K Pk k k[( ) ] ( ) = 2 1 11 ...(2.2c)

    ThisvalueoftheKalmangaingivesthebestcompromisebetweentherateatwhich Pk decreases

    with kandthesteady-statevariance,thatis,Pk for large k.

    Inamultivariatesystem,thestatevariablexk is an n-dimensionalvector,wheren is the number of

    variableswhosevaluesdenethestateoftheplant.Themeasuredvalueyk is an n-dimensional

    vector,ifduringeachsamplingperiod,thereadingsofn sensors are taken. We let A denote the

    measurementmatrix;itisan n nmatrixthatrelatesthe n measured variables to the n state

    variables.Inotherwords,

    yk = Axk + ek

    The vector ek gives the additive noise in each of the nmeasuredvalues.Eq.(2.2a)becomesan

    n-dimensional vector equation

    xk = x K y Axk k k k + 1 1( ) ...(2.3)

    Similarly,Kalmangain Kk and variance PkaregivenbythematrixversionofEqs.(2.2b)and

    (2.2c).So,thecomputationineachsamplingperiodinvolvesafewmatrixmultiplicationsand

    additionsandonematrixinversion.

    TheAtanasoffBerryComputer(ABC)wasthefirstelectronicdigital

    computingdevice.

    Self Assessment

    Choose the correct answer:

    1. Outputofahigher-levelcontrollerisareferenceinputofoneormorelower-levelcontrollers.

    (a) True (b) False. 2. Theanalogueversionisthentransformedintoadigital(i.e.,discrete-timeanddiscrete-state)

    version. The resultant controller is a..................

    (a) panelsystem (b) multiratesystem

    (c) sampleddatasystem (d) noneofthese.

    3. A discrete-time control scheme that has no continuous-time equivalence is...............

    (a) deadbeatcontrol (b) multiratecontrol

    (c) sampledcontrol (d) noneofthese.

    4. Theresponsetimeofthecomputationcanvaryfromperiodtoperiod.

    (a) True (b) False.

    5. .isacommonlyusedmeanstoimprove the accuracyofmeasurementsandtoestimatemodelparametersinthepresenceofnoiseanduncertainty.

    (a) Deadbeatcontrol (b) Multiratecontrol

    (c) Kalmanlter (d) noneofthese.

    2.2 High-Level Controls

    Controllersinacomplexmonitorandcontrolsystemaretypicallyorganizedhierarchicallywith

    fewexceptions,oneormoreofthehigher-levelcontrollersinterfaceswiththetor(s).

    2.2.1 Examples of Control Hierarchy

    Forexample,apatientcaresystemmayconsistofmicroprocessor-basedcontrollersthatmonitor

    andcontrolthepatientsbloodpressure,respiration,glucose,andsoforth.Theremayahigher-

  • 7/27/2019 DCAP608_real Time System

    27/237

    Unit 2: Introduction to Real Time Applications

    LOVELY PROFESSIONAL UNIVERSITY 21

    Noteslevelcontroller(e.g.,inexpertsystem)whichinteractswiththeoperator(anordoctor)andchoosesthedesiredvaluesofthesehealthindicators.Whilethecomputationdonebyeachdigitalcontrollerissimpleandnearlydeterministic,thecomputationofahigh-levelcontrollerislikelytobefarmorecomplexandvariable.Whiletheperiodofalevelcontrol-lawcomputationrangesfrommilliseconds

    toseconds,theperiodsofhigh-levelcontrol-lawcomputationsmaybeminutes,evenhours.Figure2.4showsamorecomplexexample:thehierarchyofightcontrol,avionics,andairtrafccontrolsystems.TheAirTrafcControl(ATC)systemisatthehighestlevel.Itregulatestheowofightstoeachdestinationairport.Itdoessobyassigningtoeachaircraftanarrivaltimeateachmeteringx(orwaypoint)enroutetothedestination:Theaircraftissupposedtoarriveatthemeteringxattheassignedarrivaltime.Atanytimewhileinighttheassignedarrivaltimetothenextmeteringxisareferenceinputtotheon-boardightmanagementsystem.Theightmanagementsystemchoosesatime-referencedightpaththatbringstheaircrafttothenextmeteringxattheassignedarrivaltime.Thecruisespeeds,turnradius,descend/ascendrates,andsoforthrequiredtofollowthechosentime-referencedightpatharethereferenceinputstotheightcontrolleratthelowestlevelofthecontrolhierarchy.

    Ingeneral,theremaybeseveralhigherlevelsofcontrol.Takeacontrolsystemof robotsthatperformassemblytasksinafactoryforexample.Pathandtrajectoryplannersatthesecondleveldeterminethetrajectorytobefollowedbyeachindustrialrobot.Theseplannerstypicallytakeasaninputtheplangeneratedbyataskplanner,whichchoosesthesequenceofassemblystepstobeperformed.Inaspacerobotcontrolsystem,theremaybeascenarioplanner,whichdetermineshowarepairorrendezvousfunctionshouldbeperformed.Theplangeneratedbythisplannerisaninputofthetaskplanner.

    2.2.2 Guidance and Control

    Whileadigitalcontrollerdealswithsomedynamicalbehaviourofthephysicalplant,asecondlevel

    controllertypicallyperformsguidanceandpathplanningfunctionstoachieveahigher-levelgoal.

    Figure 2.4: Air Trafc/Flight Control Hierarchy

    Responses Commands

    Operator-system

    interface

    From

    sensors

    Stateestimator

    Air-trafficcontrol

    NavigationVirtual plant

    Stateestimator

    Stateestimator

    Flightmanagement

    Flightcontrol

    Virtual plant

    Air data

    Physical plant

  • 7/27/2019 DCAP608_real Time System

    28/237

    Real Time Systems

    22 LOVELY PROFESSIONAL UNIVERSITY

    Notes Inparticular,ittriestondoneofthemostdesirabletrajectoriesamongalltrajectoriesthat

    meettheconstraintsofthesystem.Thetrajectoryismostdesirablebecauseitoptimizessome

    costfunction(s).Thealgorithm(s)usedforthispurposeis thesolution(s)ofsomeconstrained

    optimizationproblem(s).

    Asanexample,welookagainataightmanagementsystem.Theconstraintsthatmustbe

    satisedbythechosenightpathincludetheonesimposedbythecharacteristicsoftheaircraft,

    suchasthemaximumandminimumallowedcruisespeedsanddecent/accentrates,aswellas

    constraintsimposedbyexternalfactors,suchasthegroundtrackandaltitudeprolespeciedby

    theATCsystemandweatherconditions.Acostfunctionisfuelconsumption:Amostdesirable

    ightpathisa mostfuelefcientamongallpathsthatmeetalltheconstraintsandwillbring

    theaircrafttothenextmeteringxattheassignedarrivaltime.Thisproblemisknownasthe

    constrainedxed-time,minimum-fuelproblem.Whentheightislate,theightmanagement

    systemmaytrytobringtheaircrafttothenextmeteringxintheshortesttime.Inthatcase,it

    willuseanalgorithmthatsolvesthetime-optimalproblem.

    Complexity and Timing Requirements

    Theconstrainedoptimizationproblemsthataguidance(orpathplanning)systemmustsolveare

    typicallynonlinear.Inprinciple,theseproblemscanbesolvedusingdynamicprogramingand

    mathematicalprogramingtechniques.Inpractice,however,optimalalgorithmsarerarelyused

    becausemostofthemarenotonlyverycomputingintensivebutalsodonotguaranteetonda

    usablesolution.Heuristicalgorithmsusedforguidanceandcontrolpurposestypicallyconsider

    oneconstraintatatime,ratherthanalltheconstraintsatthesametime.Theyusuallystartwith

    aninitialcondition(e.g.,inthecaseofaightmanagementsystems,theinitialconditionincludes

    theinitialposition,speed,andheadingoftheaircraft)andsomeinitialsolutionandadjustthe

    valueofonesolutionparameteratatimeuntilasatisfactorysolutionisfound.

    Fortunately,aguidancesystemdoesnotneedtocomputeitscontrollawsasfrequentlyasadigital

    controller.Often,thiscomputationcanbedoneoff-line.Inthecaseofaightmanagementsystem,

    forexample,itneedstocomputeandstoreaclimbspeedscheduleforuseduringtakeoff,an

    optimumcruisetrajectoryforuseenroute,andadescenttrajectoryforlanding.Thiscomputation

    canbedonebeforetakeoffandhenceisnottime-critical.Whilein-ight,thesystemstillneedsto

    computesomecontrollawstomonitorandcontrolthetransitionsbetweendifferentightphases

    (i.e.,fromclimbtocruiseandcruisetodescent)aswellasalgorithmsforestimatingandpredicting

    timestowaypoints,andsoforth.Thesetime-criticalcomputationstendtobesimplerandmore

    deterministicandhaveperiodsinorderofsecondsandminutes.Whenthepre-computedight

    planneedstobeupdatedoranewonecomputedin-ight,thesystemhasminutestocompute

    andcanacceptsuboptimalsolutionswhenthereisnotime.

    Other Capabilities

    Thecomplexityofahigher-levelcontrolsystemarisesformanyotherreasonsinadditionto

    itscomplicatedcontrolalgorithms.Itofteninterfaceswiththeoperatorandothersystems.To

    interactwiththeoperator,itupdatesdisplaysandreactstooperatorcommands.Byothersystems,

    wemeanthoseoutsidethecontrolhierarchy.Anexampleisavoice,telemetry,ormultimedia

    communication system thatsupports operatorinteractions. Other examplesare radar and

    navigationdevices.Thecontrolsystemmayusetheinformationprovidedbythesedevicesand

    partiallycontrolthesedevices.

    Anavionicorightmanagementsystemhasthesecapabilities.Oneofitsfunctionsistoupdate

    thedisplayofradar,ightpath,andair-datainformation.Likekeyboardmonitoring,thedisplay

    updatesmustdonenolessfrequentlythanonceevery100millisecondstoachieveasatisfactory

    performance.Similarly,itperiodicallyupdatesnavigationdataprovidedbyinertialandradio

    navigation aids. An avionics system for a military aircraft also does tracking and ballistic

  • 7/27/2019 DCAP608_real Time System

    29/237

    Unit 2: Introduction to Real Time Applications

    LOVELY PROFESSIONAL UNIVERSITY 23

    Notescomputationsandcoordinatesradarandweaponcontrolsystems,anditdoesthemwithrepetition

    periodsofafewtoafewhundredmilliseconds.Theworkloadduetothesefunctionsisdemanding

    evenfortodaysfastprocessorsanddatalinks.

    2.2.3 Real-time Command and ControlThecontrolleratthehighestlevelof,acontrolhierarchyisacommandandcontrolsystem.An

    AirTrafcControl(ATC)systemisanexcellentexample.Figure2.5showsapossiblearchitecture.

    TheATCsystemmonitorstheaircraftinitscoverageareaandtheenvironment(e.g.,weather

    condition)andgeneratesandpresentstheinformationneededbytheoperators(i.e.,theairtrafc

    controllers).OutputsfromtheATCsystemincludetheassignedarrivaltimestometeringxes

    forindividualaircraft.Asstatedearlier,theseoutputsarereferenceinputstoon-boardight

    managementsystems.Thus,theATCsystemindirectlycontrolstheembeddedcomponentsinlow

    levelsofthecontrolhierarchy.Inaddition,theATCsystemprovidesvoiceandtelemetrylinksto

    on-boardavionics.Thusitsupportsthecommunicationamongtheoperatorsatbothlevels(i.e.,

    thepilotsandairtrafccontrollers).

    TheATCsystemgathersinformationonthestateofeachaircraftviaoneormoreactiveradars.Suchradarinterrogateseachaircraftperiodically.

    Figure 2.5: An Architecture of Air Trafc Control System

    Digital

    signalprocessors

    Database oftrack recordsand tracks

    Communication network

    DP DP Surveillanceprocessor

    Display processors

    Displays

    Communicationnetwork

    DSP DSP DSP

    Sensors

    DB DB

    Wheninterrogated,anaircraftrespondsbysendingtotheATCsystemitsstatevariables:

    identier,position,altitude,heading,andsoon.(InFigure2.5,thesevariablesarereferred

  • 7/27/2019 DCAP608_real Time System

    30/237

    Real Time Systems

    24 LOVELY PROFESSIONAL UNIVERSITY

    Notes tocollectivelyasatrackrecord,andthecurrenttrajectoryof theaircraftisa track.)TheATC

    systemprocessesmessagesfromaircraftandstoresthestateinformationthusobtainedina

    database.Thisinformationispickedupandprocessedbydisplayprocessors.Atthesametime,

    asurveillancesystemcontinuouslyanalyzesthescenarioandalertstheoperatorswheneverit

    detectsanypotentialhazard(e.g.,apossiblecollision).Again,theratesatwhichhumaninterfaces(e.g.,keyboardsanddisplays)operatemustbeatleast10Hz.Theotherresponsetimescanbe

    considerablylarger.Forexample,theallowedresponsetimefromradarinputsisonetotwo

    seconds,andtheperiodofweatherupdatesisintheorderof10seconds.

    Fromthisexample,wecanseethatacommandandcontrolsystembearslittleresemblanceto

    low-levelcontrollers.Incontrast toa low-levelcontrollerwhoseworkloadiseitherpurelyor

    mostlyperiodic,acommandandcontrolsystemalsocomputesandcommunicatesinresponseto

    sporadiceventsandoperatorscommands.Furthermore,itmayprocessimageandspeech,query

    andupdatedatabases,simulatevariousscenarios,andthelike.Theresourceandprocessingtime

    demandsofthesetaskscanbelargeandvaried.Fortunately,mostofthetimingrequirementsof

    acommandandcontrolsystemarelessstringent.Whereasalow-levelcontrolsystemtypically

    runsononecomputerorafewcomputersconnectedbyasmallnetworkordedicatedlinks,a

    command and control system is often a large distributed system containing tens and hundredsofcomputersandmanydifferentkindsofnetworks.Inthisrespect,itresemblesinteractive,on-

    linetransactionsystems(e.g.,astockpricequotationsystem)whicharealsosometimescalled

    real-time systems.

    2.3 Signal Processing

    Mostsignalprocessingapplications have some kind of real-time requirements. We focus here

    onthosewhoseresponsetimesmustbeunderafewmillisecondstoafewseconds.Examples

    aredigitalltering,videoandvoicecompressing/decompression,andradarsignalprocessing.

    Signalprocessingisanareaofsystemsengineering,electricalengineeringandappliedmathematics

    thatdealswithoperationsonoranalysisofsignals,ineitherdiscreteorcontinuoustime.Signalsofinterestcanincludesound,images,time-varyingmeasurementvaluesandsensordata,for

    examplebiologicaldatasuchaselectrocardiograms,controlsystemsignals,telecommunication

    transmissionsignals,andmanyothers.Signalsareanalogordigitalelectricalrepresentationsof

    time-varyingorspatial-varyingphysicalquantities.Inthecontextofsignalprocessing,arbitrary

    binarydatastreamsandon-offsignallingarenotconsideredassignals,butonlyanaloganddigital

    signalsthatarerepresentationsofanalogphysicalquantities.

    2.3.1 Processing Bandwidth Demands

    Typically,a real-timesignalprocessingapplicationcomputesineachsamplingperiodoneor

    moreoutputs.Eachoutputx(k)isaweighted sum of ninputsy(i)s:

    x(k) = a k i y i

    i

    n

    ( , ) ( )

    =

    1

    Inthesimplestcase,theweights,a (k, i)s,areknownandxed.In essence,thiscomputation

    transforms the given representationofanobject(e.g.,avoice,animageoraradarsignal)interms

    oftheinputs,y(i)s,intoanotherrepresentationintermsoftheoutputs, x(k)s.Differentsetsof

    weights,a(k,i)s,givedifferentkindsoftransforms.Thisexpressiontellsusthatthetime-required

    toproduceanoutputisO(n).

    Theprocessortimedemandofanapplicationalsodependsonthenumberofoutputsitisrequired

    toproduceineachsamplingperiod.Atoneextreme,adigitallteringapplication(e.g.,alter

    thatsuppressesnoiseandinterferencesinspeechandaudio)producesoneoutputeachsampling

    period.ThesamplingratesofsuchapplicationsrangefromafewkHztotensofkHz.Then

    ranges from tens to hundreds. Hence,suchanapplicationperforms104to107multiplications

    andadditionspersecond.

  • 7/27/2019 DCAP608_real Time System

    31/237

    Unit 2: Introduction to Real Time Applications

    LOVELY PROFESSIONAL UNIVERSITY 25

    NotesSome other signalprocessingapplicationsaremorecomputationallyintensive.Thenumberofoutputsmayalsobeofordern,andthecomplexityofthecomputationisO(n2)ingeneral.Anexampleisimagecompression.Mostimagecompressionmethodshaveatransformstep.Thissteptransformsthespacerepresentationofeachimageintoatransformrepresentation(e.g.,a

    hologram).To illustratethecomputationaldemandofa compressionprocess,let usconsideran m mpixel,30framespersecondvideo.Supposethatweweretocompresseachframebyrstcomputingitstransform.Thenumberofinputsisn =m2. The transformation of each frametakes m4multiplicationsandadditions.Ifmis100,thetransformationofthevideotakes3109multiplicationsandadditionspersecond!Onewaytoreducethecomputationaldemandattheexpenseofthecompressionratioistodivideeachimageintosmallersquaresandperformthetransformoneachsquare.ThisindeediswhatthevideocompressionstandardMPEG[IS094])does.Eachimageisdividedintosquaresof88pixels.Inthisway,thenumberofmultiplicationsandadditionsperformedinthetransformstageisreducedto64m2perframe(inthecaseofour

    example,to1.92107).Today,thereisabroadspectrumofDigitalSignalProcessors(DSPs)designed specicallyfor signal processingapplications.ComputationallyintensivesignalprocessingapplicationsrunononeormoreDSPs.Inthisway,thecompressionprocesscankeeppacewiththerateatwhichvideoframesarecaptured.

    2.3.2 Radar System

    Asignalprocessingapplicationistypicallyapartofalargersystem.Asanexample,Figure2.6showsablockdiagramofa(passive)radarsignalprocessingandtrackingsystem.Thesystem

    consistsofanInput/Output(I/O)subsystemthatsamplesanddigitizestheechosignalfromtheradarandplacesthesampledvaluesinasharedmemory.Anarrayofdigitalsignalprocessorsprocessesthesesampledvalues.Thedatathusproducedareanalyzedbyoneormoredataprocessors,whichnotonlyinterfacewiththedisplaysystem,butalsogeneratecommandstocontroltheradarandselectparameterstobeusedbysignalprocessorsinthenextcycleofdatacollection and analysis.

    Radar Signal Processing

    Tosearchforobjectsofinterestinitscoveragearea,theradarscanstheareabypointingitsantenna

    inonedirectionatatime.Duringthetimetheantennadwellsinadirection,itrstsendsashortradiofrequencypulse.Itthencollectsandexaminestheechosignalreturningtotheantenna.

    Theechosignalconsistssolelyofbackgroundnoiseifthetransmittedpulsedoesnothitanyobject.Ontheotherhand,ifthereisareectiveobject(e.g.,anairplaneorstormcloud)atadistancexmetersfromtheantenna,theechosignalreectedbytheobjectreturnstotheantenna

    atapproximately2x/csecondsafterthetransmittedpulse,wherec=3108meterspersecondisthespeedoflight.

    Figure 2.6: Radar Signal Processing and Tracking System

    Sampled

    digitized

    data

    Signalprocessors

    DSP

    2561024samples/bin

    Trackrecords

    Trackrecords

    Control

    status

    Dataprocessor

    Signal

    processingparameters

    Memory

    Radar

  • 7/27/2019 DCAP608_real Time System

    32/237

    Real Time Systems

    26 LOVELY PROFESSIONAL UNIVERSITY

    Notes Theechosignalcollectedatthistimeshouldbestrongerwhenthereisnoreectedsignal.Ifthe

    objectismoving,thefrequencyofthereectedsignalisnolongerequaltothatofthetransmitted

    pulse.Theamountoffrequencyshift(calledDopplershift)isproportionaltothevelocityofthe

    object.Therefore,byexaminingthestrengthandfrequencyspectrumoftheechosignal,thesystem

    can determine whetherthereareobjectsinthedirectionpointedatbytheantennaandifthere

    areobjects,whattheirpositionsandvelocitiesare.

    Specically,thesystemdividesthetimeduringwhichtheantennadwellstocollecttheechosignal

    intosmalldisjointintervals,Eachtimeintervalcorrespondstoadistancerange,andthelengthof

    the interval is equal to the range resolution divided by c.(Forexample,ifthedistanceresolution

    is300meters,thentherangeintervalisonemicrosecondlong.)Thedigitalsampledvaluesof

    the,echosignalcollectedduringeachrangeintervalareplacedinabuffer,calledabininFigure

    2.6.Thesampledvaluesineachbinaretheinputsusedbyadigitalsignalprocessortoproduce

    outputsoftheformgivenbyEq.(2.3).TheseoutputsrepresentadiscreteFouriertransformof

    thecorrespondingsegmentoftheechosignal.Basedonthecharacteristicsofthetransform,the

    signalprocessordecideswhetherthereisanobjectinthatdistancerange.Ifthereisanobject,it

    generates a track record containingthepositionandvelocityoftheobjectandplacestherecord

    in the shared memory.

    ThetimerequiredforsignalprocessingisdominatedbythetimerequiredtoproducetheFourier

    transforms,andthistimeisnearlydeterministic.ThetimecomplexityofFastFourierTransform

    (FFT)isO(n log n),where nis thenumberofsampledvaluesineachrangebin.nistypically

    intherangefrom128 toa few thousand. So, ittakes roughly103to105multiplicationsand

    additionstogenerateaFouriertransform.Supposethattheantennadwellsineachdirectionfor

    100millisecondsandtherangeoftheradarisdividedinto1000rangeintervals.Thenthesignal

    processingsystemmustdo107to109multiplicationsadditionspersecond.Thisiswellwithin

    thecapabilityoftodaysdigitalsignalprocessors.

    However,the100-milliseconddwelltimeisaballparkgureformechanicalradarantennas.Thisisordersofmagnitudelargerthanthatforphasearrayradars,suchasthoseusedinmanymilitary

    applications.Phasearrayradarcanswitchthedirectionoftheradarbeamelectronically,within

    amillisecond,andmayhavemultiplebeamsscanningthecoverageareaandtrackingindividual

    objects at the same time. Since the radar can collect data orders of magnitude faster than the rates

    statedabove,thesignalprocessingthroughputdemandisalsoconsiderablyhigher.Thisdemand

    ispushingtheenvelopeofdigitalsignalprocessingtechnology.

    TheSCR-268(forSignalCorpsRadiono.268)wastheUSArmysrstradar

    system.

    Tracking

    Strongnoiseandman-madeinterferences,includingelectroniccountermeasure(i.e.,jamming),canleadthesignalprocessinganddetectionprocesstowrongconclusionsaboutthepresenceof

    objects.Atrackrecordonanon-existingobjectiscalledafalsereturn.Anapplicationthatexamines

    allthetrackrecordsinordertosortoutfalsereturnsfromrealonesandupdatethetrajectories

    of detected objects is called a tracker.Usingthejargonofthesubjectarea,wesaythatthetracker

    assignseachmeasuredvalue(i.e.,thetupleofpositionandvelocitycontainedineachofthetrack

    recordsgeneratedinascan)toatrajectory.Ifthetrajectoryisanexistingone,themeasuredvalue

    assignedtoitgivesthecurrentpositionandvelocityoftheobjectmovingalongthetrajectory.If

    thetrajectoryisnew,themeasuredvaluegivesthepositionandvelocityofapossiblenewobject.

    IntheexampleinFigure2.6,thetrackerrunsononeormoredataprocessorswhichcommunicate

    withthesignalprocessorsvia the shared memory.

  • 7/27/2019 DCAP608_real Time System

    33/237

    Unit 2: Introduction to Real Time Applications

    LOVELY PROFESSIONAL UNIVERSITY 27

    NotesGating

    Typically,trackingiscarriedoutintwosteps:gatinganddataassociation.Gatingistheprocess

    ofputtingeachmeasuredvalueintooneoftwocategoriesdependingonwhetheritcanorcannot

    betentativelyassignedto oneormoreestablishedtrajectories. Thegatingprocesstentativelyassigns a measured value to an established trajectory if it is within a threshold distance G away

    fromthepredictedcurrentpositionandvelocityoftheobjectmovingalongthetrajectory.(Below,

    wecallthedistancebetweenthemeasuredandpredictedvaluesthedistanceoftheassignment.)

    ThethresholdGiscalledthetrackgate.Itischosensothattheprobabilityofavalidmeasured

    valuefallingintheregionboundedbyasphereofradiusGcentredonapredictedvalueisa

    desired constant.

    Figure2.7illustratesthisprocess.Atthestart,thetrackercomputesthepredictedposition(and

    velocity)oftheobjectoneachestablishedtrajectory.Inthisexample,therearetwoestablished

    trajectories;L1 and L2Wealsocallthepredictedpositionsoftheobjectsonthesetracks L1 and

    L2. The X1,X2 and X3 are the measured values given by three track records. The X1 is assigned

    to L1 because it is within distance G from L1. The X3 is assigned to both L1 and L2 for the same

    reason.Ontheotherhand,X2isnotassignedtoanyofthetrajectories.Itrepresentseitherafalse

    returnoranewobject.Sinceitisnotpossibletodistinguishbetweenthesetwocases,thetracker

    hypothesizesthatX2isthepositionofanewobject.Subsequentradardatawillallowthetracker

    toeithervalidateor invalidatethishypothesis.Inthe lattercase,the trackerwilldiscardthis

    trajectory from further consideration.

    Figure 2.7: Gating Process

    Data Association

    Thetrackingprocesscompletesif,aftergating,everymeasuredvalueisassignedtoatmostone

    trajectory and every trajectory is assigned at most one measured value. This is likely to be case

    when(1)theradarsignalisstrongandinterferenceislow(andhencefalsereturnsarefew)and

    (2)thedensityofobjectsislow.Underadverseconditions,theassignmentproducedbygating

    maybeambiguous,thatis,somemeasuredvalueisassignedtomorethanonetrajectoryora

    trajectoryisassignedmorethanonemeasuredvalue.Thedataassociationstepisthencarried

    outtocompletetheassignmentsandresolveambiguities.

    There are many data association algorithms. One of the most intuitive is the nearest neighbour

    algorithm.Thisalgorithmworksasfollows:

    1. Examinethetentativeassignmentsproducedbythegatingstep.

    (a) Foreachtrajectorythatistentativelyassignedasingleuniquemeasuredvalue,assign

    themeasuredvaluetothetrajectory.Discardfromfurtherexaminationthetrajectory

    andthemeasuredvalue,togetherwithalltentativeassignmentsinvolvingthem.

    (b) Foreachmeasuredvaluethatistentativelyassignedtoasingletrajectory,discardthe

    tentative assignments of those measured values that are tentatively assigned to this

    trajectory if the values are also assigned to some other trajectories.

    2. Sort the remaining tentative assignments in order of non-decreasing distance.

  • 7/27/2019 DCAP608_real Time System

    34/237

    Real Time Systems

    28 LOVELY PROFESSIONAL UNIVERSITY

    Notes 3. Assign themeasuredvaluegivenbythersttentativeassignmentin thelist tothe

    correspondingtrajectoryanddiscardthemeasuredvalueandtrajectory.

    4. Repeatstep(3)untilthelistoftentativeassignmentsisempty.

    IntheexampleinFigure2.7,thetentativeassignmentproducedbythegatingstepisambiguous.Step(1a)doesnoteliminateanytentativeassignment.However,step(1b)ndsthatX1 is assigned

    to only L1,whileX3 is assigned to both L1 and L2.Hence,theassignmentofX3 to L1 is discarded

    fromfurtherconsideration.Afterstep(1),therestillaretwo,tentativeassignments,X1 to L1 and

    X3 to L2.Step(2)leavestheminthisorder,andthesubsequentstepsmaketheseassignments.

    The X2initiatesanewtrajectory.Ifduringsubsequentscans,nomeasuredvaluesareassigned

    tothenewtrajectory,itwillbediscardedfromfurtherconsideration.

    Thenearestneighbouralgorithmattemptstominimizeasimplelocalobjectivefunction:the

    distance(betweenthemeasuredandpredictedvalues)ofeachassignment.Dataassociation

    algorithms ofhigher time complexityare designed tooptimizesomeglobal, andtherefore

    morecomplicated,objectivefunctions,forexample,thesumofdistancesofallassignments

    andprobabilityoferrors.Themostcomplexinbothtimeandspaceistheclassofmultiple

    hypothesistrackingalgorithms.Oftenitisimpossibletoeliminatesomeassignmentsfromfurther

    considerationbylookingatthemeasuredvaluesproducedinonescan.(Anexampleiswhenthe

    distancesbetweenmeasuredvaluestotwoormorepredictedvaluesareessentiallyequal.)While

    asingle-hypothesistrackingalgorithm(e.g.,thenearestneighbouralgorithm)mustchooseone

    assignmentfromequallygoodassignments,amultiple-hypothesistrackingalgorithmkeepsall

    ofthem.Inotherwords,atrajectorymaybetemporallybranchedintomultipletrajectories,each

    endingatoneofmanyhypothesizedcurrentpositions.Thetrackerthenusesthedataprovided

    infuturescanstoeliminatesomeofthebranches.Theuseofthiskindofalgorithmsisconned

    towherethetrackedobjectsaredenseandthenumberoffalsereturnsarelarge(e.g.,fortracking

    militarytargetsinthepresenceofdecoysandjamming).

    Complexity and Timing Requirements

    Incontrasttosignalprocessing,theamountsofprocessortimeandmemoryspacerequiredby

    thetrackeraredatadependentandcanvarywidely.Whenthereare n established trajectories

    and mmeasuredvalues,thetimecomplexityofgatingisO(nm log m).(Thiscanbedonebyrst

    sorting the mmeasuredvaluesaccordingtotheirdistancesfromthepredictedvalueforeachof

    theestablishedtrajectoriesandthencomparingthedistanceswiththetrackgateG.)Intheworst

    case,allm measured values are tentatively assigned to all ntrajectoriesinthegatingstep.The

    nearest neighbour algorithm must sort all nmtentativeassignmentsandhencehastimecomplexity

    O(nm log nm).Theamountsoftimeandspacerequiredbymultiple-hypothesistrackinggrow

    exponentiallywiththemaximumnumberofhypotheses,theexponentbeingthenumberofscans

    requiredtoeliminateeachfalsehypothesis.Withoutmodernfastprocessorsandlargememory,

    multiplehypothesistrackingwouldnotbefeasible.

    Figure2.6showsthattheoperationoftheradariscontrolledbya controllerthatexecutesonthedataprocessor.Inparticular,thecontrollermayalterthesearchstrategyorchangetheradar

    operationmode(sayfromsearchingtotrackinganobject)dependingontheresultsfoundby

    thetracker.Similarly,thecontrollermayalterthesignalprocessingparameters(e.g.,detection

    thresholdandtransformtype)inordertobemoreeffectiveinrejectinginterferencesand

    differentiatingobjects.Theresponsivenessanditerationrateofthisfeedbackprocessincreaseas

    thetotalresponsetimeofsignalprocessingandtrackingdecreases.Forthisreason,thedevelopers

    oftheseapplicationsareprimarilyconcernedwiththeirthroughputsandresponsetimes.

    Createastructureusingtheradarsysteminacollegecampus.

  • 7/27/2019 DCAP608_real Time System

    35/237

    Unit 2: Introduction to Real Time Applications

    LOVELY PROFESSIONAL UNIVERSITY 29

    Notes2.4 Other Real-time Applications

    Thecharacteristicsandrequirementsoftwomostcommonreal-timeapplications.Theyarereal-

    timedatabasesandmultimediaapplications.

    Table 2.1: Requirements of Typical Real-Time Databases

    Applications Size Ave. Max Abs. Cons. Rel. Cons. Permanence

    Airtrafccontrol 20,000 0.50ms 5.00ms 3.00sec. 6.00sec. 12 hours

    Aircraft mission 3,000 0.05ms 1.00ms 0.05sec. 0.20sec. 4 hours

    Spacecraftcontrol 5,000 0.05ms 1.00ms 0.20sec. 1.00sec. 25 years

    Processcontrol 0.80ms 5.00sec 1.00sec. 2.00sec 24 hours

    2.4.1 Real-time Databases

    Thetermreal-timedatabasesystemsreferstoadiversespectrumofinformationsystems,rangingfromstockpricequotationsystems,totrackrecordsdatabases,toreal-timelesystems.Table2.1

    listsseveralexamples.Whatdistinguishesthesedatabasesfromnonreal-timedatabasesisthe

    perishablenatureofthedatamaintainedbythem.

    Specically,areal-timedatabasecontainsdataobjects,called image objectsthatrepresentreal-

    worldobjects.Theattributesofanimageobjectarethoseoftherepresentedreal-worldobject.

    Forexample,anairtrafccontroldatabasecontainsimageobjectsthatrepresentaircraftinthe

    coveragearea.Theattributesofsuchanimageobjectincludethepositionandheadingof the

    aircraft.Thevaluesoftheseattributesareupdatedperiodicallybasedonthemeasuredvaluesof

    theactualpositionandheadingprovidedbytheradarsystem.Withoutthisupdate,thestored

    positionandheadingwilldeviatemoreandmorefromtheactualpositionandheading.Inthis

    sense,thequalityofstoreddatadegrades.Thisiswhywesaythatreal-timedataareperishable.

    Incontrast,anunderlyingassumptionofnonreal-timedatabases(e.g.,apayrolldatabase)isthatintheabsenceofupdatesthedatacontainedinthemremaingood(i.e.,thedatabaseremainsin

    someconsistentstatesatisfyingallthedataintegrityconstraintsofthedatabase).

    Absolute Temporal Consistency

    Thetemporalqualityofreal-timedataisoftenquantiedbyparameterssuchasageandtemporal

    dispersion.Theageofadataobjectmeasureshowup-to-datetheinformationprovidedbythe

    objectis.Therearemanyformaldenitionsofage.Intuitively,theage of an image object at any time

    isthelengthoftimesincetheinstantofthelastupdate,thatis,whenitsvalueismadeequalto

    thatofthereal-worldobjectitrepresents.Theageofadataobjectwhosevalueiscomputedfrom

    the values of other objects is equal to the oldest of the ages of those objects.

    Asetofdataobjectsissaidtobeabsolutely(temporally)consistentifthemaximumageofthe

    objectsinthesetisnogreaterthanacertainthreshold.ThecolumnlabelledAbs.Cons.inTable

    2.1liststhetypicalthresholdvaluesthatdeneabsoluteconsistencyfordifferentapplications.As

    anexample,aircraftmissionlistedinthetablereferstothekindofdatabaseusedtosupport

    combatmissionsofmilitaryaircraft.Aghterjetandthetargetsittracksmoveatsupersonic

    speeds.Hencetheinformationonwheretheyaremustbelessthan50millisecondsold.Onthe

    otherhand,anairtrafccontrolsystemmonitorscommercialaircraftatsubsonicspeeds;thisis

    whytheabsolutetemporalconsistencythresholdforairtrafccontrolismuchlarger.

    Relative Temporal Consistency

    A set of data objects is said to be relatively consistentifthemaximumdifferenceinagesoftheobjects

    inthesetisnogreaterthantherelativeconsistencythresholdusedbytheapplication.Thecolumn

    labelledRel.Cons.inTable2.1givestypicalvaluesofthisthreshold.Forsomeapplications

  • 7/27/2019 DCAP608_real Time System

    36/237

    Real Time Systems

    30 LOVELY PROFESSIONAL UNIVERSITY

    Notes theabsoluteageofdatamaynotbeasimportantasthedifferencesintheirages.Anexampleisa

    planningsystemthatcorrelatestrafcdensitiesalongahighwaywiththeowratesofvehicles

    enteringandexitingthehighway.Thesystemdoesnotrequirethemostup-to-dateowratesat