Page 1

9RO,VV<HDU

,QWO-UQORQ+XPDQ0DFKLQH,QWHUDFWLRQ

RealÇŚTimeTaskforEmbeddedControlSystems LISI,INSAT,Tunis,Tunisia ITIA,CNRInstitute,Italy

co m

AtefGharbi,MohamedKhalgui,SamirBenAhmed

w w w .a sd fjo ur na ls .

FST,UniversityofElManar,Tunis,Tunisia  Abstractâ&#x20AC;&#x201D;ThispaperdealswiththestudyofRealÇŚTimeTasksforEmbeddedControlSystemsfollowing componentÇŚbased technology. A realÇŚtime task is assumed to be a set of components having some properties independently from any realÇŚtime operating system.  We apply the Priority Ceiling Protocol (PCP)asamethodtoensuretheschedulingbetweenperiodictaskswithprecedenceandmutualexclusion constraints.WesimulatetheschedulingofRealÇŚtimetaskswithPCPthroughtheCheddartool. KeywordsÇŚRealÇŚTimeTasks;EmbeddedControlSystem;Simulation;PriorityCeilingProtocol(PCP) I.

Introduction

Nowadays, the time to market the embedded systems is becoming shorter and the cost of development is beingcheaper.Inordertorealizethisgoal(i.e.reducingtimeandcost),thedesignersofembeddedsystem proposetoreusethealreadydeveloppedsoftwarecomponents. Themainbenefitsofcomponentare:(i) theseparationofconcernswhichmeansthateachcomponentcanbedefinedaloneafterthatallthesystem can be reproduced; (ii) the modification of   component is very simple (such as modification of data, algorithm,connection,â&#x20AC;Ś);(iii)theadaptationofcomponenttoanymodification; (iv)thereuseof component(itisnotspecificforonlyoneapplication).

fro m

However,therearefewkindsofcomponentÇŚbasedtechnologies(suchasKoala[1],PBO[2],PECOS[3],â&#x20AC;Ś) usedinthedevelopmentofembeddedcontrolsystemduetoextraÇŚfunctionalpropertiestobeverified(for example quality of service, timeliness, â&#x20AC;Ś) [4]. Anyway, each componentÇŚbased technology has its benefits anditsdrawbacks.

D ow nl oa de d

Althoughcomponenttechnologiesdealsuccessfullywithfunctionalattributes,theyprovidenosupportfor managing extraÇŚfunctional properties of systems (such as synchronization, memory optimization, power consumption, and temporal attributes) that cannot be encapsulated in one component with wellÇŚdefined interfacesastheycrosscutthestructureoftheoverallsystem.Todoso,wedefineattheoperationallevel some sequential program units called realÇŚtime tasks. Thus, we define a realÇŚtime task as a set of componentshavingsomerealÇŚtimeconstraints.Wecharacterizeataskbyasetofpropertiesindependently fromanyRealTimeOperatingSystem(RTOS). WestudyinparticulartheschedulingoftasksthroughaRealTimeOperatingSystem.Weapplythepriority ceilingprotocolproposedby[5]toavoidtheproblemofpriorityinversionaswellasthedeadlockbetween thedifferenttasks.Thepriorityceilingprotocolsupposesthateachsemaphoreisassignedapriorityceiling whichisequaltothehighestprioritytaskusingthissemaphore.Anytaskisonlyallowedtoenteritscritical sectionifitsassignedpriorityishigherthanthepriorityceilingsofallsemaphorescurrentlylocked byothertasks.Thecontributionsofthisresearchworkhavebeenappliedtothebenchmarkingproduction system:FESTOsystem(usedasrunningexample)allowingustovalidateourresults. The Section 2 presents the benchmark production system (FESTO system). We define in Section 3  the schedulingwiththePriorityCeilingProtocol.TheSection4treatsthesimulationofrealÇŚtimetaskswiththe Cheddartool.Finally,weconcludeinthelastsection.

MRXUQDOV#DVGIUHVLQ

ZZZDVGIMRXUQDOVFRP

3DJHRI


9RO,VV<HDU

,QWO-UQORQ+XPDQ0DFKLQH,QWHUDFWLRQ

II.

BenchmarkProductionSystem

w w w .a sd fjo ur na ls .

co m

We present  the Benchmark Production System (Detailed descriptions are available in the website: http://aut.informatik.uniÇŚhalle.de) : FESTO available in the research laboratory at the Martin Luther UniversityinGermany.TheFESTOBenchmarkProductionSystemisawellÇŚdocumenteddemonstratorused bymanyuniversitiesforresearchandeducationpurposes,anditisusedasarunningexampleinthecontext of this paper. FESTO is composed of three units: Distribution, Test and Processing units (Figure 1). The Distributionunitiscomposedofapneumaticfeederandaconvertertoforwardcylindricalworkpiecesfrom astacktothetestingunitwhichiscomposedofthedetector,thetesterandtheelevator.Thisunitperforms checksonworkpiecesforheight,materialtypeandcolor.Workpiecesthatsuccessfullypassthischeckare forwardedtotherotatingdiskoftheProcessingunit,wherethedrillingoftheworkpieceisperformed.We assumeinthisresearchworktwodrillingmachinesDrill_machine1andDrill_machine2todrillpieces.The resultofthedrillingoperationisnextcheckedbythecheckingmachineandtheworkpieceisforwardedto anothermechanicalunit.

fro m





Figure1.TheFESTOsystem

TaskSchedulingWithPriorityCeilingProtocol

D ow nl oa de d

III.

Howtoscheduleperiodictaskswithprecedenceandmutualexclusionconstraintsisconsidered asimportantashowtorepresentataskinageneralrealÇŚtimeoperatingsystem.Inourcontext,wechoose the priorityÇŚdriven preemptive scheduling used in the most realÇŚtime operating systems. The semaphore solution can lead to the problem of priority inversion  which consists that a high priority task can be blocked by a lower priority task. To avoid such problem, we propose to apply the priority inheritance protocolproposedby(Sha,1990). Thepriorityinheritanceprotocolcanbeusedtoscheduleasetofperiodictaskshavingexclusiveaccessto commonresourcesprotectedbysemaphores.Todoso,eachsemaphoreisassignedapriorityceilingwhich isequaltothehighestprioritytaskusingthissemaphore.Atask * i isallowedtoenteritscriticalsection

onlyifitsassignedpriorityishigherthanthepriorityceilingsofallsemaphorescurrentlylockedbytasks otherthan * i .

Schedulability test for the priority ceiling protocol: a set of n periodic tasks using the priority ceiling protocolcanbescheduledbytherateÇŚmonotonicalgorithmifthefollowinginequalitieshold,

MRXUQDOV#DVGIUHVLQ

ZZZDVGIMRXUQDOVFRP

3DJHRI


9RO,VV<HDU

,QWO-UQORQ+XPDQ0DFKLQH,QWHUDFWLRQ

 i,1Ď?iĎ?n,C1/T1+C2/T2+â&#x20AC;Ś+Ci/Ti+Bi/TiĎ?i(21/iÇŚ1)

whereBidenotestheworstÇŚcaseblockingtimeofatask * i bylowerprioritytasks.

co m

 Running Example. In the FESTO Benchmark Production System, we consider three tasks R1 (a reconfigurationtask),S1andS2(servicetasks)havingaspriorityp1,p2andp3suchthatp1>p2>p3.

w w w .a sd fjo ur na ls .

The sequence of processing steps for each task is as defined in the section previous paragraph where S (resp.R)denotestheservice(resp.reconfiguration)semaphore: R1={â&#x20AC;ŚP(R)executereconfigurationV(R)â&#x20AC;Ś} S1={â&#x20AC;ŚP(S)â&#x20AC;ŚP(R)â&#x20AC;ŚV(S)executeserviceP(S)â&#x20AC;ŚV(R)â&#x20AC;ŚV(S)â&#x20AC;Ś} S2={â&#x20AC;ŚP(S)â&#x20AC;ŚP(R)â&#x20AC;ŚV(S)executeserviceP(S)â&#x20AC;ŚV(R)â&#x20AC;ŚV(S)â&#x20AC;Ś}

Therefore,thepriorityceilingofthesemaphoreRisequaltothetaskR1(becausethesemaphoreRisused bythetasksR1,S1andS2andweknowthatthetaskR1isthehighestpriority)andthepriorityceilingofthe semaphore S is equal to the task S1 (because the semaphore S is used  by the tasks  S1 and S2 and  the prioritytaskofS1ishigher). WesupposethatthetaskS2isrunningwhenthetaskS1iscreatedattheinstantt3.Wesupposealsothat thetaskR1iscreatedattheinstantt5. IntheFigure2,alineinahighlevelindicatesthatthetaskisexecuting,alineinalowlevelindicatesthat thethetaskisblockedorpreemptedbyanothertask. ThefollowingTable2explainsmoreindetailstheexample. TABLEI.

TheeventanditscorrespondingactionintheFigure2

Event

Action

S2beginsexecution.

t1 t2

S2locksS.ThetaskS2inheritsthepriorityofS. ThetaskS1iscreated.AsithasmoreprioritythanS2,itbeginsitsexecution.

t3

t6

ThetaskS1failstolockSasitspriorityisnothigherthanthepriorityceilingofthelocked S.ThetaskS2resumestheexecutionwiththeinheritedpriorityofS. The task S2 locks R. The task S2 inherits the priority of R. The task R1 is created and preemptsthe(executionofS2asithasthehighestpriority). ThetaskR1failstolockRasitspriorityisnothigherthanthepriorityceilingofthelocked R.ThetaskS2resumestheexecutionofthecriticalsection.  ThetaskS2unlocksS.

t7

ThetaskS2executesaservice.

t8

ThetaskS2locksS.

t9

t10

The task S2 unlocks R  and therefore has as priority the same as S. The task R1 becomes havingthehighestpriority.AsithasmoreprioritythanS2,itresumesitsexecution. ThetaskR1locksR.

t11

ThetaskR1executesthereconfiguration.

t12

ThetaskR1unlocksR.

t13 t14

ThetaskR1terminatesitsexecution. ThetaskS2unlocksS(thusS2becomeshavingthelowestpriority).Therefore,thetaskS1

D ow nl oa de d

t4

fro m

t0

t5

MRXUQDOV#DVGIUHVLQ

ZZZDVGIMRXUQDOVFRP

3DJHRI


9RO,VV<HDU

,QWO-UQORQ+XPDQ0DFKLQH,QWHUDFWLRQ

resumesitsexecution. ThetaskS1locksS.

t16

ThetaskS1locksR.

t17 t18 t19

ThetaskS1unlocksS. ThetaskS1executesitsservice. ThetaskS1locksS.

t20

ThetaskS1unlocksR.

t21

ThetaskS1unlocksS.

t22

ThetaskS1achievesitsexecution.

t23

ThetaskS2resumestheexecutionandterminatesitsservice.



w w w .a sd fjo ur na ls . 

fro m

 

co m

t15

Figure2.ThepriorityceilingprotocolappliedtothreetasksR1,S1andS2

SimulationWithTheCheddarTool

D ow nl oa de d

IV.

Cheddar, developed at the University of Brest, is a free realÇŚtime scheduling tool (http://beru.univÇŚ brest.fr/~singhoff/cheddar). It is used to check temporal properties on realÇŚtime systems or  applications. Thetoolprovidesasimulationengineandfeasibilitytests(Figure3). 

 Figure3.CheddarArchitecture

MRXUQDOV#DVGIUHVLQ

ZZZDVGIMRXUQDOVFRP



3DJHRI


9RO,VV<HDU

,QWO-UQORQ+XPDQ0DFKLQH,QWHUDFWLRQ

TheuseofCheddarisverysimplethroughitsgraphicalinterface. First of all,   a processor must be defined via the Edit/Update processors. To do so,  a name, a scheduler policyandthenature(itispreemptiveornot)mustbeindicated.

co m

Secondly,amemoryaddressisprecisedintheEdit/Updateaddressspacesbyspecifyingitsname.

w w w .a sd fjo ur na ls .

Finally,allthetaskshavetobedefinedintheEdit/Updatetasksbyindicatingitscharacteristics.  SchedulingwithCheddar 9 Definitionoftheprocessor:WeaimtosimulatethePriorityCeilingProtocolwiththeCheddartool. For that reason,  we define a processor  by giving him a name (Processor1), and  choosing as scheduler "POSIX 1003.1b/Highest Priority First". We choose a preemptive scheduling which is RTEMS_PREEMPT(Figure4).



Figure4.Definitionofaprocessor



We add also a space of addressing associated with the processor by indicating its name and  the processortowhichitisassociated.

fro m

Definitionofthetasks:Itisnecessarytodefinethetasksandtheirproperties.Thereare4typesof tasks, periodic, aperiodic, fish or parametric.  The kind of task which  interest us here is periodic. Afterthat, it is necessary to choose between policies SCHED_FIFO or SCHED_RR used for the schedulingofthesametaskpriority.Inthiscase,wechooseSCHED_FIFO.Itisalsonecessaryto define the priority of the task. The priorities varies from 1 to 255, highest being 255.  Lastly, it is necessarytospecifywork,startingtimes,deadline,andtheperiod.These parameters are all obligatorily. In our example, we create three tasks (T1, T2 and  T3) having as priority respectively (1, 2 and 1) (Figure5).

D ow nl oa de d

9

 Figure5.DefinitionofataskwithCheddar

MRXUQDOV#DVGIUHVLQ

ZZZDVGIMRXUQDOVFRP

3DJHRI


9RO,VV<HDU

Definition of the resource: As we need semaphores, resources should be added. We indicate the name of the resource, his initial value, and the intervals during which a task wants to reach the resource. These intervals cannot be null, i.e. a semaphore cannot be taken then delivered immediately. It is also necessary to specify the resource sharing protocol.  Under Cheddar, the protocolsavailablewereNoProtocol,PIP,PCPorIPCP. Inourexample,wedefinearesource(resource1)associatedwiththePCP.ThetaskT1needstouse thisresourceduringtheinterval[2,3]whereasthetasksT2wantstouseitduringtheinterval[2,5] (Figure6).

w w w .a sd fjo ur na ls .



9

co m



,QWO-UQORQ+XPDQ0DFKLQH,QWHUDFWLRQ



D ow nl oa de d

fro m

Figure6.Definitionofaresource  TheFigure7depictsananalysisofthistestcasebyCheddar.Thetoppartofthewindowshowsthethread scheduling.Theworstcaseresponsetimecomputedfromthisschedulingandwithfeasibilitytestsareshown inthebottompartofthewindow. 

 Figure7.SchedulingwiththeCheddartool V.

Conclusion

ThispaperhasasobjectivethestudyofRealÇŚTimeTaskforEmbeddedControlSystem.Weusethepriority ceilingprotocolasamethodtoensuretheschedulingbetweenperiodictaskswithprecedenceandmutual exclusionconstraints.

MRXUQDOV#DVGIUHVLQ

ZZZDVGIMRXUQDOVFRP

3DJHRI


9RO,VV<HDU

,QWO-UQORQ+XPDQ0DFKLQH,QWHUDFWLRQ

The novelty of this paper is the study of dynamic reconfiguration with semaphore ensuring the following points: (i) blocking connections without blocking involved components; (ii) safety and correctness of the proposed solution; (iii) independence of any specific language; (iv) verification of consistency (i.e. logical constraints);(v)suitableforlargeÇŚscaleapplications.

References [1]

[2]

 [3]

 [4]

 [5]

Roel Wuyts, Stephane Ducasse and Oscar Nierstrasz, â&#x20AC;&#x153;A dataÇŚcentric approach to composing embedded, realÇŚtime software componentsâ&#x20AC;?, The Journal of Systems and Software (74), pages 25ÇŚ34, 2005. Ed Brinksma and  all, â&#x20AC;&#x153;ROADMAP: ComponentÇŚbased Design and Integration Platformsâ&#x20AC;?, http://www.artistÇŚembedded.org,2003. L. Sha, R. Rajkumar and J.P. Lehoczky, â&#x20AC;&#x153;Priority Inheritence Protocols: An Approach to RealÇŚTime Synchronizationâ&#x20AC;?, IEEETrans.onComputers.Vol.39(9)(pp.1175ÇŚ1185)},1990.

D ow nl oa de d

fro m

    

Merijn de Jonge, â&#x20AC;&#x153;Developing Product Lines with ThirdÇŚParty Componentsâ&#x20AC;?, Electronic Notes in TheoreticalComputerScience,pages63ÇŚ80,2009.  David B. Stewart, Richard A. Volpe and Pradeep K. Khosla,  â&#x20AC;&#x153;Design of Dynamically Reconfigurable RealÇŚTimeSoftwareUsingPortÇŚBasedObjectsâ&#x20AC;?, IEEE Transactions on Software Engineering (23), pages592ÇŚ600,1997.

w w w .a sd fjo ur na ls .



co m

Inthefuturework,wewillbeinterestedintheproblemofallocationofrealÇŚtimetaskstothedevicesofthe executionenvironmentandtheassignmentoftheseinstancestotheoperatingsystems.

MRXUQDOV#DVGIUHVLQ

ZZZDVGIMRXUQDOVFRP

3DJHRI

Ijhmi0005