Real-time operating system

Definition

Real-timeoperatingsystemisanoperatingsystemthatguaranteestocompletespecificfunctionswithinacertaintimelimit.Real-timeoperatingsystemsaredividedintohardreal-timeandsoftreal-time.Hardreal-timerequirestheoperationtobecompletedwithinthespecifiedtime,whichisguaranteedduringthedesignoftheoperatingsystem;softreal-time,aslongastheoperationiscompletedasquicklyaspossibleaccordingtothepriorityofthetaskThat'sit.Theoperatingsystemweusuallyusecanbecomeareal-timeoperatingsystemafteracertainchange.

Forexample,anoperatingsystemcanbedesignedtoensurethatarobotonaproductionlinecanacquireanobject.Ina"hard"real-timeoperatingsystem,ifthecalculationtomaketheobjectreachablecannotbecompletedwithintheallowedtime,theoperatingsystemwillendduetoanerror.Inthe"soft"real-timeoperatingsystem,theproductionlinecanstillcontinuetowork,buttheoutputoftheproductwillslowdownbecausetheproductcannotarrivewithintheallowabletime,whichmakestherobothaveashort-termnon-productionphenomenon.Somereal-timeoperatingsystemsaredesignedforspecificapplications,whileothersaregeneral-purpose.Somegeneral-purposeoperatingsystemscallthemselvesreal-timeoperatingsystems.Buttosomeextent,mostgeneral-purposeoperatingsystems,suchasMicrosoft'sWindowsNTorIBM'sOS/390,havethecharacteristicsofareal-timesystem.Thismeansthatevenifanoperatingsystemisnotastrictreal-timesystem,theycanalsosolvesomereal-timeapplicationproblems.

Ingeneral,thereal-timeoperatingsystem(RTOS)requires:

  • Multitasking

  • ProcessingcanbePrioritizedprocesslines

  • Asufficientnumberofinterruptlevels

tobeinstalledaspartofthemicrodeviceSmalloperatingsystemsoftenrequirereal-timeoperatingsystems.Somecoreissuescanbeconsideredtomeettherequirementsofreal-timeoperatingsystems.However,becauseothercomponentssuchasdevicedriversareusuallyrequiredbyspecialmethods,areal-timeoperatingsystemisusuallylargerthanthecore.

Real-timetasks

Theremustbeanumberofreal-timetasksinareal-timesystem.Thesetasksareusuallyrelatedtocertainexternaldevicesandcanreactorcontrolthecorrespondingexternaldevices.Thereisacertaindegreeofurgency.Real-timetaskscanbeclassifiedfromdifferentperspectives.

AccordingtowhetherthetaskappearsduringexecutionPeriodicchangesDivided:

a.PeriodReal-timetask

Theexternaldeviceperiodicallysendsoutanexcitationsignaltothecomputer,requiringittobeexecutedcyclicallyaccordingtoaspecifiedperiodinordertoperiodicallycontrolacertainexternaldevice.

b.Non-periodicreal-timetasks

Theexcitationsignalssentbyexternaldeviceshavenoobviousperiodicity,buttheymustbelinkedtoadeadline.Itcanbedividedintotwoparts:startdeadline(taskmustbeexecutedbeforeacertaintime)andcompletiondeadline(taskmustbecompletedbeforeacertaintime).

Dividedaccordingtothedeadlinerequirements:

a,hardreal-timetasks

b,softreal-timetasks

Features

1)High-precisiontimingsystem

Timingaccuracyisanimportantfactoraffectingreal-timeperformance.Inreal-timeapplicationsystems,itisoftennecessarytoaccuratelydeterminewhethertooperateacertaindeviceorperformacertaintaskinrealtime,ortoaccuratelycalculateatimefunction.Thesenotonlyrelyontheclockaccuracyprovidedbysomehardware,butalsorelyonthehigh-precisiontimingfunctionimplementedbythereal-timeoperatingsystem.

2)Multi-levelinterruptmechanism

Areal-timeapplicationsystemusuallyneedstoprocessavarietyofexternalinformationorevents,buttheurgencyoftheprocessingisdifferent.Somemustrespondimmediately,whileotherscanbepostponed.Therefore,amulti-levelinterruptnestingprocessingmechanismneedstobeestablishedtoensuretimelyresponseandprocessingofreal-timeeventswithahigherdegreeofurgency.

3)Real-timeschedulingmechanism

Thereal-timeoperatingsystemmustnotonlyrespondtoreal-timeeventinterruptsintime,butalsoscheduleandrunreal-timetasksintime.However,processorschedulingcannotbecarriedoutarbitrarily,becausetheswitchingbetweentwoprocessesisinvolved,anditcanonlybecarriedoutatatimepointtoensure"safeswitching".Thereal-timeschedulingmechanismincludestwoaspects,oneistheschedulingstrategyandThealgorithmguaranteespriorityschedulingofreal-timetasks;thesecondistoestablishmore"safehandover"timepointstoensuretimelyschedulingofreal-timetasks.

Comparison

Comparisonofcharacteristicsofreal-timesystemandtime-sharingsystem

(1)Multiplex.Thereal-timeinformationprocessingsystemisasmultipathasthetime-sharingsystem.Thesystemservesmultipleendusersaccordingtothetime-sharingprinciple;whileforreal-timecontrolsystems,itsversatilityismainlymanifestedinthefrequentcollectionofmultipleon-siteinformationandthecontrolofmultipleobjectsormultipleactuators.

(2)Independence.Thereal-timeinformationprocessingsystemisasindependentasthetime-sharingsystem.Wheneachterminalusermakesaservicerequesttothetime-sharingsystem,theyoperateindependentlyofeachotheranddonotinterferewitheachother;andinthereal-timecontrolsystem,thecollectionofinformationandthecontrolofobjectsdonotinterferewitheachother.

(3)Timeliness.Thereal-timerequirementsofthereal-timeinformationsystemaresimilartothoseofthetime-sharingsystem,whicharedeterminedbytheacceptablewaitingtime;whilethetimelinessofthereal-timecontrolsystemisbasedonthestartdeadlineorthecompletiondeadlinerequiredbythecontrolobjectTobesure,itisgenerallyintheorderofseconds,hundredsofmillisecondstomilliseconds,andsomeevenlessthan100microseconds.

(4)Interactivity.Thereal-timeinformationprocessingsystemisinteractive,buttheinteractionbetweenpeopleandthesystemislimitedtoaccessingcertainspecialserviceprogramsinthesystem.Itisnotlikeatime-sharingsystemthatcanprovideenduserswithdataprocessingservices,resourcesharingandotherservices.

(5)Reliability.Thetime-sharingsystemrequiresthesystemtobereliable,incontrast,thereal-timesystemrequiresthesystemtobehighlyreliable.Becauseanymistakesmaybringhugeeconomiclossesorevenunforeseencatastrophicconsequences.Therefore,inthereal-timesystem,multi-levelfault-tolerantmeasuresaretakentoensurethesafetyofthesystemandthesafetyofdata.

Relatedconcepts

Basicconcepts

Codecriticalsection:referstotheindivisiblecodeduringprocessing.Oncethispartofthecodeisexecuted,interruptionisnotallowed;

Resources:anyentityoccupiedbythetask;

Sharedresources:resourcesthatcanbeusedbymorethanonetask;

Task:Alsocalledathread,itisasimpleprogram.Eachtaskisgivenacertainpriority,hasitsownsetofCPUregistersanditsownstackspace.Typically,eachtaskisaninfiniteloop,andeachtaskisinthefollowingfivestates:sleepstate,readystate,runningstate,suspendedstate,andinterruptedstate;

taskSwitch:savethecurrentstateoftherunningtask(allcontentsintheCPUregister)inthetask'sownstackarea,andthenreloadthecurrentstateofthenexttasktoberunintotheCPUregisterfromthetaskstack,andStarttheoperationofthenexttask;

Kernel:Responsibleformanagingeachtask,allocatingCPUtimeforeachtask,andresponsibleforcommunicationbetweentasks.Dividedintoinalienablekernelanddeprivablekernel;

Scheduling:Oneofthemainresponsibilitiesofthekernel,decidingwhichtaskistorun.Generallybasedonpriorityschedulingmethod;

Priorityproblem

Taskpriority:dividedintostaticprioritywithunchangeablepriorityanddynamicprioritywithchangeablepriority;

Priorityreversal:Priorityreversalisthemostcommonprobleminreal-timesystems.Theallocationofsharedresourcescancauselow-prioritytaskstorunfirst,andhigh-prioritytaskstorunlater.Thesolutionistousethe"priorityinheritance"algorithmtotemporarilychangethetaskprioritytopreventpriorityinversion.

Mutualexclusion

Althoughtheshareddataareasimplifiestheexchangeofinformationbetweentasks,eachtaskmustbeguaranteedtobeexclusivewhenprocessingsharedshareddata.Thegeneralmethodstosatisfythemutuallyexclusiveconditionsare:turnofftheinterrupt,usethetestandsetinstruction(TAS),prohibittaskswitching,andusethesemaphore.

Becausethesignificanceofusingareal-timeoperatingsystemistobeabletohandlevariousemergenciesintime,thatis,todealwithvariousinterrupts,thusmeasuringthemostimportantandrepresentativeperformanceindicatorsoftheembeddedreal-timeoperatingsystemTheparametershouldundoubtedlybetheinterruptresponsetime.Interruptresponsetimeisusuallydefinedas:

Interruptresponsetime=interruptdelaytime+timetosavetheCPUstate+executiontimeofthecoreISRintothefunction.

Interruptdelaytime=MAX(thelongesttimetoclosetheinterrupt,thelongestinstructiontime)+thetimetostartexecutingthefirstinstructionoftheISR.

Maximuminterruptprohibitiontime:

WhenRTOSisrunninginnuclearstateorexecutingcertainsystemcalls,itwillnotinterruptexecutionduetothearrivalofexternalinterrupts.OnlywhentheRTOSreturnstotheusermodewillitrespondtotheexternalinterruptrequest.Themaximumtimerequiredforthisprocessisthemaximuminterruptprohibitiontime.

Taskswitchingtime:

Whenataskquitsrunningforsomereason,RTOSsavesitsrunningsiteinformation,insertsthecorrespondingqueue,andreselectsaccordingtoacertainschedulingalgorithmAtaskputsitintooperation,thetimerequiredforthisprocessiscalledtaskswitchingtime.

Amongtheaboveitems,themaximuminterruptprohibitiontimeandtaskswitchingtimearethetwomostimportanttechnicalindicatorsforevaluatingthereal-timeperformanceofanRTOS.

Related Articles
TOP