An Esterel Virtual Machine for Embedded Systems

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

SLAP2006

AnEsterelVirtualMachineforEmbedded

Systems

BeckyPlummer1

DepartmentofComputerScienceColumbiaUniversityNewYork,USA

MukulKhajanchi2

DepartmentofComputerScienceColumbiaUniversityNewYork,USA

StephenA.Edwards3

DepartmentofComputerScienceColumbiaUniversityNewYork,USA

Abstract

Embeddedsystemsoftensufferfromsevereresourceconstraintssuchaslimitedmemoryforprogramsanddata.Inthiswork,weaddresstheproblemofcompilingtheEsterelsynchronouslanguageforprocessorswithsuchconstraints.

Weintroduceavirtualmachinethatexecutesacompactbytecodedesignedspecif-icallyforexecutingEsterelandpresentacompilerforit.OurtechniquegeneratescodethatisroughlyhalfthesizeofoptimizedCcodecompiledusingexistingtech-niques.

WedemonstratetheutilityofourapproachontheLegoRCXcontrollerfortheMindstormssystem.WhilewearenotthefirsttoexecuteEsterelontheRCX,ourtechniquewillallowlargerprogramsthanwerepreviouslypossible.

1Email:rp2176@columbia.edu2Email:mk2603@columbia.edu3Email:sedwards@cs.columbia.eduEdwardsandhisgroupatColumbiaaresupportedbyanNSFCAREERaward,agrantfromIntelcorporation,anawardfromtheSRC,andfromNewYorkState’sNYSTARprogram.http://www.cs.columbia.edu/˜sedwardsThispaperiselectronicallypublishedinElectronicNotesinTheoreticalComputerScienceURL:www.elsevier.nl/locate/entcsPlummer,Khajanchi,andEdwards

1Introduction

Embeddedsystemsusuallyhavelimitedresourcessuchaspower,size,compu-

tationspeed,andmemory.Akeychallenge,then,inimplementingembedded

systemsismeetingrequirementswithintheselimits.

Inthiswork,weaddresstheproblemofrunningreactive,embeddedpro-

grams,specificallyprogramswrittenintheEsterelsynchronouslanguage[2],

inaconstrained-memoryenvironment.WeproposeanEsterelvirtualmachine

whoseinstructionsethasdirectsupportforEsterelconstructs—specifically

concurrency—thatotherwiserequireafairamountofcodeonanormal,se-

quentialprocessor.Wesimultaneouslydevelopedacompilerforthevirtual

machinethatproducesbytecodethatisroughlyone-halfthesizeofanequiv-

alentoptimizednativeexecutable.

WeimplementedourvirtualmachineontheHitachiH8-basedRCXmi-

crocontrollerthatispartoftheLegoMindstormssystem.

Codecompressionforembeddedsystemisawell-studiedtopicthathasled

toindustrialsolutionssuchasARM’sThumbinstructionset.Thisreplaces

thestandard32-bitARMinstructionsetwitha16-bitvariantthatomits

manyinstructionsandregistercombinations.Itgenerallyprovidesa20–30%

reductionincodesize.Whileusingsuchacompactinstructionsetoncompiled

Esterelcodewouldcertainlywork,thevirtual-machine-basedapproachwe

proposeachievessignificantlyhighercompressionratios.

RunningEsterelontheRCXmicrocontrollerisalsonotnovel,havingbeen

achievedbeforebyChristopheMaurasandMartinRichard4,withsomehelp

fromXavierFornari.Theirapproach,however,ismoretraditional:likeus,

theyusetheBrickOSenvironmentastheirlow-levelinterfacetothehardware,

butuseastandardEsterelcompilerthatgeneratesCthatiscross-compiled

ontotheH8microcontroller;theircontributionismostlyinprovidinganAPI.

Roopetal.[7]haveproposedanEsterel-specificinstructionset,buttheir

focuswasonefficiency,notcodesize,andtheirapproachappearstobelim-

itedtoEsterelprogramswithnoconcurrency.Forthesereasons,wedidnot

attempttofollowtheirworkindesigningourvirtualmachine.

Ourcompilationtechnique,builtontheColumbiaEsterelCompiler[4]

translatestheGRC-likeintermediaterepresentation[6,5]usedwithinCEC

intoabytecodeofourowndevising.Wedescribetheintermediaterepresen-

tationinSection2andthebytecodeinSection3.

Ourtwocontributionsarethevirtualmachineandthecompilationalgo-

rithm,which,likethealgorithmdevisedbyEdwardsfortheSynopsysEsterel

compiler[3],translatesaconcurrentcontrol-flowgraph(i.e.,GRC)intoase-

quentialprogramwithexplicitcontextswitches.WedescribethisinSection4.

Finally,wepresentexperimentalresultsonourLegoRCXimplementation

inSection6.

4http://www.emn.fr/x-info/lego/

2Plummer,Khajanchi,andEdwards

2EsterelandtheGRCrepresentation5

Berry’sEsterellanguage[2]isanimperativeconcurrentlanguagewhosemodel

oftimeresemblesthatinasynchronousdigitallogiccircuit.Theexecution

oftheprogramprogressesacycleatatimeandineachcycle,theprogram

computesitsoutputandnextstatebasedonitsinputandthepreviousstate

bydoingaboundedamountofwork;nointra-cycleloopsareallowed.

Esterelisaconcurrentlanguageinthatitsprogramsmaycontainmultiple

threadsofcontrol.Unliketypicalmulti-threadedsoftwaresystems,however,

Esterel’sthreadsexecuteinlockstep:eachseesthesamecycleboundariesand

communicateswithotherthreadsusingadisciplinedbroadcastmechanism.

Esterel’sthreadscommunicatethroughsignals,whichbehavelikewiresin

digitallogiccircuits.Ineachcycle,eachsignaltakesasingleBooleanvalue

(presentorabsent)thatdoesnotautomaticallypersistbetweencycles.Inter-

threadcommunicationissimple:withinacycle,anythreadthatreadsthe

valueofasignalmustwaitforanyotherthreadsthatsetthatsignal’svalue.

StatementsinEstereleitherexecutewithinacycle(e.g.,emitmakesa

givensignalpresentinthecurrentcycle,presenttestsasignal)ortakeone

ormorecyclestocomplete(e.g.,pausedelaysacyclebeforecontinuing,await

waitsforacycleinwhichaparticularsignalispresent).Strongpreemption

statementscheckaconditionineverycyclebeforedecidingwhethertoallow

theirbodiestoexecute.Forexample,theeverystatementperformsareset-like

actionbyrestartingitsbodyinanycycleinwhichitspredicateistrue.

Esterel’ssemanticsrequireanyimplementationtodealwiththreeissues:

theconcurrentexecutionofsequentialthreadsofcontrolwithinacycle,the

schedulingconstraintsamongthesethreadsduetocommunicationdependen-

cies,andhow(control)stateisupdatedbetweencycles

2.1TheGRCRepresentation

ConsiderthesmallEsterelprograminFig.1(a).Itmodelsasharedre-

sourceusingthreegroupsofconcurrently-runningstatements.Thefirstgroup

(awaitIthroughemitO)takesarequestfromtheenvironmentonsignalI

andpassesittothesecondgroupofstatements(loopthroughendloop)on

signalR.ThesecondgrouprespondstorequestsonRwiththesignalAin

alternatecycles.

ThissimpleexampleillustratesmanychallengingaspectsofcompilingEs-

terel.Forexample,thefirstthreadcommunicateswithandrespondstothe

secondthreadinthesamecycle,i.e.,thepresenceofRisinstantaneously

broadcasttothesecondthread,which,ifthepresentstatementisrunning,

observesRandimmediatelyemitsAinresponse.Inthesamecycle,emittingA

causestheweakabortstatementtoterminateandsendcontroltoemitO.

5MuchofthissectionwastakenfromEdwards,Kapadia,andHalas[4].

3

相关文档
最新文档