• No results found

Qinna: a component-based framework for runtime safe resource adaptation of embedded systems

N/A
N/A
Protected

Academic year: 2020

Share "Qinna: a component-based framework for runtime safe resource adaptation of embedded systems"

Copied!
12
0
0

Loading.... (view fulltext now)

Full text

(1)

QINNA:A COMPONENT-BASEDFRAMEWORK FOR RUNTIME SAFERESOURCE

ADAPTATION OFEMBEDDED SYSTEMS

LAURE GONNORD

AND JEAN-PHILIPPE BABAU

Abstrat. Evenifhardwareimprovementshaveinreasedthe performaneof embeddedsystemsinthe lastyears,resoure

problems arestillaute. Thepersisting problem isthe onstantly growing omplexityof systems,whih inreasethe needfor

reusabledevelopementframeworkandpieesofode. IntheaseofPDAsandsmartphones,inadditiontolassialneeds(safety,

seurity),developersmustdealwithqualityofservie(QoS)onstraints,suhasresouremanagement.

Qinnawasdesignedtofaewiththeseproblems.Inthispaper,weproposeaompleteframeworktoexpressressoureonstraints

duringthedeveloppementproess. Weproposeaomponent-basedarhiteture,whihgeneriomponentsandalgorithms,anda

developpementmethodology,tomanageQoSissueswhiledevelopinganembeddedsoftware. Theobtainedsoftwareisthenableto

automatiallyadaptitsbehaviour tothephysialresoures, thankstodegradedmodes. Weillustratethemethodologyandthe

useofQinnawithinaasestudy.

Keywords: omponent,softwarearhiteture,resouredynamimanagement,asestudy.

1. Introdution. Whenfaedtotheproblemofdesigninghandledembeddedsystems,thedevelopermust

beawareofthemanagementoflimitedphysialresoures(CPU,Memory).

Inordertodevelopmultimediasoftwareonsuhsystemswherethequalityoftheresoure(network,battery)

anvaryduring use,thedeveloperneedstoolsto:

easilyadd/removefuntionality(servies)during ompilationorat runtime;

adaptomponentfuntionalitytoresoures,namelyproposedegradedmodeswhereresouresarelow;

evaluatethesoftware'sperformanes: qualityofprovidedservies,onsumptionrateforsomesenarios. Inthisontext,omponent-basedsoftwareengineeringappearsasapromisingsolutionforthedevelopment

ofsuh kindsofsystems. Indeeditoersaneasierwaytobuildomplexsystemsfrom baseomponents([9℄),

andthemanagementofphysialresoureanbedonebyembeddingthesystemallsinhighlevelomponents.

Themainadvantagesthusappeartobethere-usabilityofodeandalsotheexibilityofsuhsystems.

TheQinnaframework( [11,12, 3℄) wasdesignedto handlethe speiationand managementofresoure

onstraints problems during the omponent-based system development. Variability is enoded into disrete

implementation levelsand links betweenthem. Quantity of resoureonstraintsanalso be enoded. Qinna

providesalgorithmstoensureresoureonstraintsanddynamiallyadapt theimplementationlevelsaording

to resoureavailabilityat runtime. The main advantageofthe methodis thenthe reusability oftheresoure

omponentsandthegeneriadaptationalgorithms.

In this journal paper, wepropose aomplete formalization of Qinna framework (algorithms and

ompo-nents),andasproofofonept,aasestudyonsistingofthedevelopmentofaremoteviewerappliationwith

thehelpofQinna'simplementationinC++. InSetion2wereallQinna'smainonepts,asintroduedin[11℄

andformalizedlaterin[3℄. InSetion3,wegiveanoverviewofQinna'sC++implementation,andthenprovide

thegeneralimplementationstepsto developaresoure-awareappliationwithQinnain Setion4. Finallywe

illustratethewholeframeworkontheviewerasestudy(Setion5).

2. Desriptionofthe Qinna framework.

2.1. Qinna'smainonepts. Theframeworkdesignedin[11℄and[12℄,andfurtherformalizedin[3℄has

thefollowingharateristis:

Boththeappliationpieesofodeandtheresoureareomponents. Theresoureserviesareenlosed inomponentslikeMemory,CPU,Thread.

The variation of quality of the provided servies are enoded by the notion of implementation level. Theodeusedtoprovidetheservieisthus dierentaordingtotheurrentimplementationlevel.

The link between the implementation levelsis made through an expliitrelation betweenthe imple-mentation levelof the provided servieand the implementationlevelsof theservies itrequires. For

instane, the developer an express that a video omponent provides an image with highest quality

whenithasenoughmemoryandsuientbandwidth.

UniversitéofLille,LIFLLaure.Gonnordlifl.fr

UBO,LISyC,UniversitéEuropéennedeBretagneJean.Philippe.Babauuniv- bre st.f rThisworkhasbeenpartiallysupported

(2)

All the alls to avariable funtion are made throughan existing ontratthat is negotiated. This negotiation is made automatially through the Qinna omponents. A ontrat for aservie at some

objetiveimplementationlevelismadeonlyifallitsrequirementsanbereservedattheorresponding

implementationlevelsandalsosatisfysomeonstraintsalledQualityofresoureonstraints(QoR).If

itnotthease,thenegotiationfails.

QoSComponentBroker1

...

QoSDomain

QoSComponentManager1

Manager2

Manager3

Broker2

Broker3

ontratmaintenane funtionalpart

admission,reservation QoSComponent

C

1

gestionpart

C

3

C

2

Fig.2.1. Arhitetureexample

These harateristis are implemented through new omponents whih are illustrated in Figure 2.1: to

eahappliationomponent(orgroupofomponents) whih provideoneormorevariableservieQinna

asso-iatesa QoSComponent

C

i

. Thevariabilityof a variableservie is made throughthe useof a orresponding

implementation levelvariable. Then,twonewomponentsareintroduedbyQinnato managetheresoure

issuesoftheinstanes ofthisQoSComponent:

a QoSComponentBroker whih goal is to realize the admission of a omponent. The Brokerdeides whetherornotanewinstaneanbereated,andifaservieallanbeperformedw.r.t. thequantity

ofresoureonstraints(QoR).

aQoSComponentManager whihmanagestheadaptationfortheserviesprovidedbytheomponent. It ontainsamappingtable whih enodetherelationshipbetweentheimplementation levels ofeah

oftheseserviesandtheirrequirements.

Atlast,Qinnaprovidesasingleomponentnamed QoSDomain forthewhole arhiteture. Itmanagesallthe

servierequests inside andoutsidetheappliation. Thelientof aservieasks theDomain forreservation of

someimplementationlevelandiseventuallyreturnedaontratifallonstraintsaresatised. Then,aftereah

servierequest,theDomain makesanaknowledgmentonlyoftheorrespondingontratisstillvalid.

2.2. Quantity of Resoure onstraints in Qinna. A Quantity of resoure onstraint (QRC) is a

quantitativeonstrainton aomponent

C

and theservie(

s

i

)it proposes. QRCsare forinstane formulaon

thetotal instane of agiven omponent type,of the totalamountof resoure(memory,CPU) alloatedto a

givenomponent. Theyaretwotypesofonstraints,depending ontheirpurpose:

Componenttypeonstraints(CTC)expresspropertiesofomponentsof thesametypeandtheir pro-videdservies.

Componentinstane onstraints(CIC)express propertiesofapartiularinstaneofaomponent. Themanagementofthese onstraintsisautomatially doneatruntime, ifthedeveloperimplementsthem

inthefollowingway:

In the QoSComponent, for eah servie, implement the twofuntions: testCIC and updateCIC. The formerdeideswhetherornotthealltotheservieanbeperformed,andthelaterupdatesvariables

afterthefuntionall. Inaddition,theremustbeaninitializationoftheCICsformulasatthereation

ofeahinstane.

Similarly,intheQoSComponentBroker,foreahprovidedservie,implementthetwofuntionstestCTC andupdateCTC.

Then,Qinnamaintainsresoureonstraintsatruntimethroughthefollowingproedure:

WhentheBrokerfor

C

isreated,theparametersused intestCTCareset.

(3)

The

CIC

(

s

i

)

and

CT C

(

s

i

)

deisionproeduresareinvokedateahfuntionall. Anegativeanswerto oneofthesedeisionproedureswillausethefailureoftheurrentontrat. Wewilldetailthenotion

ofontratin Setion2.4.

ExampleThe Memoryomponent provides only oneservie mallo, whih hasonly one parameter, the

numberof bloks to alloate. It hasanintegerattribute, memory,whih denotes theglobal memory sizeand

is set at thereation ofeah instane. We also supposethat we havenogarbage olletor, so the bloks are

alloatedonlyone. Figure2.2illustratesthedierenebetweentypeandinstaneonstraints.

CTC:

memory

1024

CIC:

memory

24

CIC:

memory

1000

P

p

(

arg

(

occ

p

(

malloc

)

1000

C

1

C

2

C

=GlobalMemory

Fig.2.2. TypevsInstaneonstraints

CTCfor

C

=Memory: theformula

CT C

compo

(

C

)

P

j

memory

(

C

j

)

1024

expressesthat theglobal memoryquantityforthewhole appliationis

1024

kilobytes. A newinstanewillnotbereatedifits

memoryonstantisset toatoobignumber. Then

CT C

serv

(

malloc

)

P

k

arg

(

occ

k

(

malloc

))

1024

forestheallstomallostopwhenallthe

1024

kilobyteshavebeenalloated.

CIC forMemory: if wewant to alloatesomeMemory for a partiular (groupof) omponent(s), we anexpresssimilarpropertiesinonepartiularinstane (see

C

1

ontheFigure).

Expressionofresoure onstraintsand ode generation

Qinnaalsoprovidesawaytodesribetheresoureonstraintsintoahigher-leverlanguagealledqMEDL,a

variantofMEDLeventlogidesribedin[6℄,andwhosepreisesyntaxandsemantisisdesribedin[3℄. Roughly

speaking, thelogianexpressbooleanformulaeonourenesofevents. Atomsareoftheform

Q ⊲⊳ K

, with

K

onstant and

⊲⊳

∈ {

6

,

=

, <, . . .

}

, and

Q

is a quantity. The quantity are obtained by the use of auxiliary variablesandalls tovalueandtimespeialfuntions: toeahevent

e

(or

new

C

),

time

(

e

)

and

value

k

(

e

)

give

respetivelythedateofthelastourreneoftheeventandthe

k

th

argumentofthefuntionallwhenitours.

TheMemory onstraint forthewhole appliation then anbe enoded by

N

1024

whereN ountsthe totalamountofmallo'sarguments: mallo -> N:=N+value_1(mallo). Thetranslationisthenmadebythe

qMEDL2toC++translator,andgivesthefollowingproedures(theidentiershavebeenhangedforlisibility,

usedmemisaloalvariableto ounttheglobalamountofmemoryusedyet):

bool testCIC_mallo(int nbbloks){

return (usedmem + nbbloks <= 1024)}

bool updateCIC_mallo(int nbbloks){

usedmem = usedmem + nbbloks; }

2.3. QoS Linking onstraints. Unlike quality of resoure onstraints, linking onstraints express the

relationshipbetweenomponents,intermsofqualityofservie. Forinstane,thefollowingpropertyisalinking

onstraint: to provide the getImages at a good level of quality, the ImageBuffer omponent requires a

big amountofmemoryandafast network. ThisrelationshipbetweenthedierentQoSoflientandserver

serviesarealled QoSLinkingServieConstraints(QLSC).

ImplementationLevelToallprovidedserviesthatanvaryaordingto thedesiredQoSweassoiate

an implementation level. This implementation level (IL) enodes whih part of implementation to hoose

when supplying the servie. These implementation levels are totally ordered for a given servie. As these

implementation levels arenitely many,weanrestritourselvesto theaseof positiveintegersandsuppose

thatimplementationlevel

0

isthebest level,

1

givesalesserqualityofservie,andsoon.

Weassumethatrequiredserviesforagivenserviedoesn'thangeaordingtotheimplementationlevel,

(4)

Linkingonstraints expressionLetusonsideraomponent

C

whihprovidesaservie

s

that requires

r

1

and

r

2

servies. Qinnapermits tolink thedierentimplementation levelsbetweenallersandallees. The

relationshipbetweenthe dierentimplementationlevelsanbeviewedasafuntion whih assoiatesto eah

implementationlevelof

s

animplementationlevelfor

r

1

andfor

r

2

:

QLSC

s

:

N

−→

N

2

IL

7−→

(

IL

1

, IL

2

)

This funtion is statially enoded by thedeveloperwithin theappliation. Forinstane, it aneasilybe

implementedintheQoSManagerthroughamapping tablewhoselinesenodethetuplesoflinked

implemen-tationlevels:

(

IL

s

1

, IL

r

1

, IL

r

2

)

. Thenaturalorderofthelinesofthetable isusedtodeterminewhihtupleto

onsideriftheurrentnegotiationfails.

linking constraint

r

2

r

1

s

1

IL

r

1

IL

r

2

IL

s

1

Fig.2.3.Implementationlevelsandlinkingonstraints

Thus,assoonasanimplementationlevelissetforthe

s

1

servie,theimplementationlevelsofallrequired

servies(and all the implementation levelsin the alltree) are set (Figure 2.3). This has aonsequenenot

onlyon theexeutedodeofall theinvolvedservies(andalso internal funtions)but also onthearguments

oftheserviealls.

Therefore,ifauserasksfortheservie

s

1

atsomeimplementationlevel,thedemandmayfailduetosome

resoureonstraint. That's whyeverydemandforaserviemustbenegotiatedandthenotionofontratwill

beauratetoimplementaset ofasatisfatoryimplementationlevelsfor(a setof)future alls.

Implementationoflinking onstraints in QinnaThelinksbetweentheprovidedQoSandtheQoSof

therequired serviesaremadethrough atable whose lines enode thetuplesof linked implementation levels:

(

IL

s

, IL

r

1

, IL

r

2

)

. Thismapping tableis enoded in the QoSManager. The naturalorder of thelines ofthe

tableisusedto determinewhihtupleto onsideriftheurrentnegotiationfails.

Nowwehavealltheelementstodenethenotionofontrat.

2.4. Qinna's ontrats. Qinna provides the notion of ontrat to ensure both behavioral onstraints

(TypeConstraintsandIntaneConstraintsofservies,asdesribedin Setion2.2)andlinkingonstraints.

Whenaservieallismadeatsomeimplementationlevel,allthesubserviesimplementationlevelarexed

impliitlythroughthelinking onstraints. Asalltheimplementationlevelsforasameservieareordered,the

objetiveis to ndthe best implementationlevelthat is feasible(w.r.t. the behavioral onstraints ofall the

omponentsandservieinvolvedinthealltree).

Contrat Negotiation All servie alls in Qinnaare made after negotiation. Theuser (at toplevel) of

the servie asks for the servie at some interval of satisfatory implementation levels. Qinna then is able

to nd the best implementation level in this interval that respets all the behavioral onstraints (CICs and

CTCs ofalltheserviesinvolvedin thealltree). If thereis nointersetionbetweenfeasibleand satisfatory

implementation levels, no ontrat is built. In theother ase, aontrat is made for the spei servie. A

ontratisthusatuple

(

id, s

i

, IL,

[

IL

min

, IL

max

]

, imp

)

denotingrespetivelyitsidentiantnumber,thereferred

servie,theurrentimplementationlevel,theintervalofsatisfatoryimplementationlevels,andtheimportane

oftheontrat. Thislastvariableisusedtosortthelistofallurrentontratsandisusedfordegradation(see

nextparagraph). Theimportane valueisstatiallyset bythedevelopereahtimeheasksforanewontrat.

Afterontratinitialization,alltheservieallsmustrespetthetermsoftheontrat. Intheotherase,

therewillbesomerenegotiation.

Contrat Maintenane and DegradationAftereahservieallthedeisionproedureforbehavioral

(5)

Domaintriestodegradetheontratofleastimportane(whihmaybenotthesameastheurrentone). This

degradationhasonsequenesontheresoureandthusanpermitotherserviealls insidetherstontrat.

Basially,degradingaontratonsistsinsettingalesserimplementationlevelamongthesatisfatoryones,

butwhihisstillfeasible. Ifitisnotpossible,theontratisstopped.

It isimportantto notie that ontratdegradationis eetiveonlyat toplevel, and thus is performed by

theDomain. It meansthat there is nodegradationofimplementation leveloutside toplevel. That iswhy we

onlyspeakofontratforservieattoplevel.

UseofserviesEahalltoaservieattoplevelasonsequenesontheontratwhihhasbeennegoiated

forhim. Wesupposethat aontratismadebeforetherstinvoationofthedesiredservie. Theveriation

ouldautomatially bedonewith Qinna, butis notnotyet implemented. All thenotiationsof failures are

loggedforthedeveloper.

3. Qinna'somponents implementationin C++. Weimplementedin C++theQinnaomponents

andalgorithms. Theseomponentsareprovidedthroughlasseswhihwedetailinthissetion.

3.1. Qinna'somponents for the managementof servies. QoSComponentTheQoSComponent

lassprovidesgenerionstrutorsanddestrutors,andontainsaprivatestruturetosavetheurrent

imple-mentationlevelsoftheomponentprovidedservie. AllQoSomponentswillinheritfrom thislass.

QoSBrokerTheQoSBrokerlassontainsaprivatestruturetosavethereferenestoalltheorresponding

omponentsitisresponsiblefor. ItprovidesthetwofuntionsFree(QoSComponent* refQ)andReserve(...).

As testCIC and updateCIC funtions signature depends of eah omponent/servie, these funtions will be

providedin eahinstane ofQoSBroker.

QoSManager TheQoSManager lass ontainsall information forthe servie provided by its assoiated

omponent. Itprovidethefollowingpublifuntions:

bool SetServieInfos(int idserv, QoSComponent *ompo, int nbreq, int nbmap) initializes themanagerfortheidservservie,providedby*ompo,withnbreqrequiredserviesandnbmapdierent

implementationlevels. Returntrueifsuessful,falseotherwise.

bool AddLevQoSReq(int idserv, int lv, int irq, int lrq) adds the tuple

(

lv, irq, lrq

)

(the

lv

implementationlevelfor

idserv

islinkedtothe

lrq

implementationlevelfor

irq

servie)inthemapping

tablefor

idserv

.

int Reserve(int idserv, int lv) is used for the reservation of the

idserv

servie at level

il

. It returns the loal number of (sub) ontrat of the Manager or

0

ifthe reservation has failed (due to

resoureonstraints).

QoSDomainTheQoSDomainlassprovidesfuntionsformanagingontratsattoplevel:

bool AddServie(int servie, int nbRq, int nbMp, QoSManager *qm) adds the servie

service

with

nbRq

requiredserviesand

nbM p

implementationlevels,withassoiatedmanager

qm

.

int Reserve(QoSComponent *ompo,int ns , int lv, int imp)is usedforreservation ofthe ser-vie

ns

providedby theomponent

compo

atlevel

lv

andimportane

imp

. it returnsthenumberof ontrat(in domain)ifsuessful,

0

otherwise.

bool Free(int id)freestheontratnumber

id

(ofdomain).

ManagerContratThislassprovidesageneristrutureforasubontratwhihenodesatupleofthe

form

< id, lv,

rq, v >

where

id

istheontratnumber,

lv

theurrentlevel,

rq

istheomponentthat provides theservie and

v

is aC++-vetorthat enode thelevelsof the requiredservies. Thislass providesaess

funtionsto thesevariablesandafuntion tohangetheimplementationlevel.

DomainContratThislass providesastruture forontratsattoplevel. A Domainontratisatuple

oftheform

< di, i, lv,

rq >

where

di

istheglobal identierofthe ontrat,

rq

is themanagerassoiatedto theomponent that provides theservie,

i

is theloal number ofsubontrat forthe manager, and

lv

is the

urrentleveloftheservie.

(6)

3.2. Basiresoureomponents. Intheallgraphofoneservie,leavesarephysialresoures(Memory,

CPU, Network). As all resouresmust be enapsulated inside omponents, we need to enapsulate the base

funtionsintoQoSComponents. Forinstane,theMemoryomponentmustbeenodedasawrapperaroundthe

mallofuntion, andtheassoiatedbrokerbasiallyimplementstheCIC funtionswhih deideif theglobal

amountofalloatedmemoryisreahedornot.

Sometimes, the basi funtions are enapsulated in higher level omponents. For instane, a high level

librarymightprovideaDisplayImagefuntionwhihmakesanexpliitalltomallo,but thisallishidden

bythe use ofthe library. Inthis partiular ase, themanagement ofbasi resourefuntions anbe donein

twodierentbut equivalentways:

thereationofaphantomMemoryomponentwhihprovidesthetwoserviesamallo(forabstrat mallo) and afree. Eah time the developer makes a all to an impliit resoure funtion (i. e.

when the alled funtion needs a signiant amount of memory, like DisplayImage), he has to all

Memory.amalllo. TheQinna's C++implementation provides somebasiomponents likeMemory,

NetworkandCPUandtheirassoiatedbrokers.

thereationofQoSComponentaroundthelibraryfuntionDisplayImagewhihisresponsible(through itsbroker)fortheglobalamountofquantityofresoureused fortheDisplayImagefuntion.

Both solutions need a preise knowledge of the libraries funtions w.r.t the resoure onsumption. We

assumethatthedeveloperhasthis knowledgesinehedesignsaresoure-awareappliation. Inourasestudy

weusedtherstsolution.

4. Methodology to use Qinna. Wesuppose that in the appliation allresoures, inluding hardware

resoures(Memory, CPU) or software ones (viewer,buer), areenoded by omponents. Here are themain

stepsforintegratingQinnaintoanexistingappliation designedin C++:

1. Identifythevariableservieswhiharefuntionswhoseallmayfailduetosomeresourereasons.

Theyareoftwotypes:

simplefuntions likeMemory.mallowhoseodedoesnotvary. Theyhaveaunique implementa-tionlevel.

adaptive funtionswhoseodeanvaryaordingto implementationlevels.

Therststepisthustoidentifytheservieswhosequalityvaryandassoiatetoeahofthisserviesa

unique key,andiftheodevary,learlyidentify thevariantodethroughaodeoftheform:

swith(implLevel)

{

ase 0 :

...

}

whereimplLevelistheassoiated(variable)attributeofthehostomponentforthisservie. Wemust

identifywhihvariableserviesarerequiredforeahprovidedservie,andtherelationshipbetweenthe

dierentimplementationlevels.

2. Create Qinna omponents. First, utthe soureodeinto QoSComponents thatan provideone

ormoreQoSservies. AstheQoSnegotiation willonlybemadebetweenQoSComponentsofdierent

types, this split will have many onsequenes on the QoS management. For eah QoSComponentC

(whih inheritsfromtheQoSComponentlass), thedesigner mustenodetwolasses: QoSBrokerCand

QoSManagerCwhih respetivelyinherit from theQoSBrokerand QoSManagergenerilasses. Forthe

wholeappliation, thedesigner willdiretlyusetheQoSDomaingenerilass.

3. ImplementQuality of Resoure onstraints. These onstraintsaresetintwodierentways:

Thetypeonstraints(CTC)foromponent

C

implementationisomposedofadditionalfuntions in

QoSBrokerC

: initCTC whih isexeuted at the reationof the Broker, andwhih sets the

deisionproeduresparameters;atestCTCfuntion todeterminewhetheranewinstaneanbe

reatedornot;anupdateCTCto savemodiationsoftheresouresafterthereation. Foreah

provided QoSservie

s

i

, weadd to newfuntions: testCTC(idsi)whih is exeuted before the

all of aservieand tellsifthe servieanbedone, and updateCTC(idsi)to beexeutedafter

theall.

The instane onstraints (CIC) for

C

are also omposed of three funtions to enode in the

(7)

de-ide if aservie of identiant ids an be alled, and updateCTC(idsi)to update the resoure

onstraintsafteraall tothe

s

i

funtion.

4. Implementthe linking onstraints. Thelinks betweenrequiredserviesand provided servievia

implementationlevelsaresetbytheinvoationoftheSetServieandAddLevQoSReqfuntionsofthe

managers. Thesefuntions willbeinvokedattoplevel.

5. Modifythe main le to initialize Qinna omponentsat toplevel. Herearethemainsteps:

Foreahbaseresoure(CPU,Memory,...)

(a) Invoketheonstrutor fortheassoiatedBroker. Theonstrutor'sargumentsmustontain

theinitialization of internal variables for type onstraints(the totalamount of memory for

example).

(b) CreatetheassoiatedManagerwiththeBrokerasargument.

() RegistertheQoSserviesinsidetheManagerthroughtheuseof SetServieInfosfuntion.

(d) Create QoSComponents instanes via theBroker.reserve(...) funtion. The arguments

anbeaertainamountofresoureusedbytheomponent.

ForalltheotherQoSComponents,therequiredomponentsrst: (a) CreatetheassoiatedBrokerand Manager.

(b) Settheserviesinformation.

() Ifaservierequiresanotherservieofanotheromponent,usethefuntion Manager.AddReq

tolinktherequiredmanager. ThenuseManager.AddLevQoSReqtosetthelinkingonstraints.

(d) Create QoSComponent instanes by invoking the orresponding reservation funtion

(Broker.Reserve).

CreatetheQoSDomainandaddtheserviesthatareusedattoplevel(Domain.AddServie)

ReserveserviesviatheQoSDomainandsavetheontrats'numbers.

5. Viewer Implementationusing Qinna.

5.1. Speiation. Ourasestudyisaremoteviewerappliationwhosehighlevelspeiationfollows:

Thesystemisomposedofamobilephoneandaremoteserver.Theappliationallowsthedownloading andthevisualizationofremoteimagesviaawirelesslink.

Theremotediretoryisreahedviaaftponnetion. Afteronnetion,twobuttonsNext and Pre-vious areusedto displayimagesonebyone. Loally,someimagesarestored inabuer. Toprovide

abetterqualityofservie,someimagesaredownloadedinadvane,whiletheoldestonesareremoved

fromthephotomemory.

Theappliation must managedierentqualities of servies forthe resoures: shortage of bandwidth andmemory,ordisonnetionsoftheftpserver. Whenneededitandownloadimagesinlowerquality

(insizeorimageompressionrate).

Dierentstoragepoliies arepossible,andtherearemanyparameterswhih anbemodied;likethe sizeofthebuer,orthenumberofimagesthataredownloadedeahtime. Wewanttoevaluatewhih

poliy isthebest aording toagiven senario.

WewanttouseQinnafortwoobjetives:

themaintenaneoftheappliationwithrespetto thedierentqualitiesofservie,

theevaluation oftheinuene oftheparameters,onthenon-funtional behavior(timingperformane andresoureusage).

5.2. Thefuntionalpart. ThefuntionalpartoftheviewerisdevelopedwithQt 1

(aC++librarywhih

providesgraphialomponentsand implementations oftheftpprotool). Figure 5.2desribesthemain parts

ofthestandaloneappliation. Wehosetomakethedownloadingpartviatheftpprotool. Thewirelesspart

isnotenoded.

TheFtpClientlassmakesaonnetiontoanexisting ftpserverand hasalistof alldistantimages. ItprovidesagetSomefuntion toenablethedownloadingofmanylesatone.

TheImageBufferlass isresponsibleforthemanagementofdownloadedles inaloal diretory. As thespeiationsays,this buerhas alimitedsize anddierentpoliyfor downloadingimages. The

lassprovidesthetwofuntions donextanddopreviouswhih are asynhronousfuntions. A signal

(8)

Fig.5.1. Sreenshotoftheviewerappliation

ImageViewer

ImageBuffer

FtpClient

init()

next/previous

donext/doprevious

connect

provided

required

downloadList

getSome

connect

Main

ImageScreen

displayImage

get

setPixmap

initBuffer

Fig.5.2.Funtionalviewoftheappliation

isthrownif/whenthedesiredimageisreadytobedisplayed. Iteventuallydownloadsfuture imagesin

urrentdiretory.

The ImageViewer lass is a high level omponent to make the interfae between the ftp and buer lassestothegraphisomponents.

The ImageSreen lass is responsible for the display of the image in a graphi omponent named QPixmap.

ThemainlassprovidesallthegraphisomponentsfortheGraphialUserInterfae.

5.3. IntegrationofQinna. Nowthatwehavethefuntionalpartoftheappliation,weaddthefollowing

resoureomponents: Memory,andNetworkwhihareQoSComponentsthatprovidevariableservies. Weonly

fous onthese twobasiresoures. TheNetwork omponentis onlylinkedtotheFtpClient,whereasMemory

willbesharedbetweenallomponents. ForMemory,theonlyvariableservieisamallowhihanfailifthe

globalamountofdediatedmemoryisreahed;thisfuntion hasonlyoneimplementationlevel. ForNetwork,

(9)

downloadList

setPixmap

Network

ImageScreen

ImageBuffer

FtpClient

initBuffer

connect

connect

ImageGUI

QoSComponent

QoSComponent instance

service with variable quality

provided

required

start

ScreenMemory

BufferMemory

Memory

Thread

thread

get donext

displayImage

getSome doprevious

get previous

next

...

amallo

amallo

Fig.5.3.Arhitetureexample

Identiationof the variableservies (step1)

Nowas thevariable serviesforlowlevel omponentshave been identied, welist thefollowingadaptive

serviesforthefuntionalpart:

ImageSreen.displayImagevariesamongmemory,ithasthreeimplementationlevelswhihorrespond tothequalityofthedisplayedimage. WeaddallstoMemory.amallofuntiontosimulatetheuseof

Memory.

Ftplient.getsome'simplementation varies among available memory and the urrent bandwidth of network.Ifthereisnotenoughmemoryornetwork,itadaptsthepoliyofthedownloads.Ithasthree

implementationlevels. WeaddallstoNetwork.bandwidthtosimulatethenetworkresouresthatare

neededtodownloadles.

ImageBuffer.donext/previousvaries among available memory: if there is notenough memory the imageissavedwithhighompression.

Creation ofthe QoSComponents(step2)

The resoure omponents are QoSComponents. Then, the three omponents ImageSreen, FtpClient

and ImageBufferare QoSComponents whih provide eah one variable servie. Imageviewer and Main are

QoSComponentsaswell. Figure5.3representsnowthestrutureoftheappliation atthisstep.

Forthesakeofsimpliity,weonlyshareMemoryintotwoparts,apartforImageBufferandtheotherpart

forimageBuffer. Thatmeansthateahoftheseomponentshavetheirownamountofmemory.

Resoure onstraints (steps 3and 4)

The quantity of resoureonstraints we have xed are lassial ones (bounds for the memory instanes,

uniqueinstantiationfortheimageSreenomponent,nomorethan80perentofbandwidthfortheftpClient,

et). TheQLSC areverysimilarto thosedesribedin [11℄foravideogameappliation. Hereweshowhowwe

haveimplementedsomeoftheseonstraintsinourappliation.

Quantity of resoure onstraints The imageSreen omponent is responsible for the unique servie display_image(displaytheimageonthegraphivideowidget). Herearesomebehavioralonstraints

weimplementedforthisomponent:

Thereisonlyoneinstaneoftheomponentone.

Thedisplayfuntion anonlydisplayimages withsizelesserorequalto

1200

800

. Thereisonlyoneallto thedisplayfuntion one.

These typeonstraintsare easily implementedin theassoiatedBroker(imageSreenBroker)in the

followingway: theonstraintmaximumofinstane requires twoprivateattributes nbinstaneand

nbinstanemaxwhih are delared andinitialized at the reationof theBrokerwith values

0

and

1

.

Then the reservation of a new imageSreen by the Broker is done after heking whether or not

(10)

The heking of memory is done by setting the global amount of memory for ImageBuffer and

imageBuffer in loal variables whih are set to

0

at the beginning of eah ontrat, and updated

eahtimethefuntion amalloisalled.

These onstraints are rather simple but we an imagine more omplex ones, provided they an be

hekedwithboundedomplexity(thisisaonstraintomingfromthefattheQinnaomponentswill

alsobeembedded).

QoSLinkingonstraints

Toillustrate the dierene between quality of resoureonstraints and linking onstraints, we show

heretheonstraintsfortheFtpClient.getSome:

Theimplementationlevel

0

orrespondsto

3

suessivedownloadswiththeNetwork.getfuntion.

Thefuntion hasauniqueimplementation levelbuteahalltoit ismadewith

60

asargument,

tomodelthefatitrequires

60

%ofthetotalbandwidth. Thesethreeallsaremadethroughthe

useoftheThread.threadwithimplementationlevel

0

(quikthread,noativewait).

Theimplementationlevel

1

orrespondsto

2

allstothegetfuntionwith

40

%ofbandwidtheah

time. ThesetwoallsaremadethroughtheuseoftheThread.threadwithimplementationlevel

1

(middlethread,fewativewait).

Theimplementationlevel

2

orrespondsto

1

allto thegetfuntionwith

20

%bandwidth. This

allismadethroughtheuseoftheThread.threadwithimplementationlevel

2

(moreativewait).

Thus if the available bandwidth is toolow, anegotiation oran existing ontrat will fail beause of the

resoureonstraints. Thereationoftheontratmayfailbeauseathreadannotbeprovidedatthedesired

implementationlevel.

Modiation of toplevel (step 5)This partisstraightforward. Theonlyhoies wehavetomakeare

the relative amount of resoure (Memory, Network) whih are alloated to eah QoSComponents. The test

senarioisdetailed insetion5.5.

5.4. Somestatistis. Thevieweriswrittenin4350linesofode,thefuntionalparttakingroughly1800

lines. The otherlines areQinna's generi omponents (1650 lo.), 600lines of odefor the newomponents

(imagesreenBroker,imageSreenManageret.) and300linesofodeforthetestsenarios. Thebinaryisalso

muhbigger 4.7Mbytes versus2MbyteswithoutQinna.

ThusQinnaisostly,but allthesupplementarylinesofodedonotneedtoberewritten,beause:

GeneriQinnaomponents,algorithms,andthebasiresoureomponentsareprovidedwithQinna.

ThedeisionfuntionsforQualityofservieonstraintsouldbeautomatiallygeneratedorbeprovided asalibraryofommononstraints.

Theinitializationattoplevelouldbeomputed-aidedthroughuser-friendlytables.

Wethink thattheostof Qinnaintermsof binaryode anbestronglyreduedbyavoidingtheexisting

redundanyinoururrentimplementation.

Moreover,Qinna'simplementationanbeviewedasaprototypetoevaluatetheresoureuseandthequality

ofserviemanagement. Afterapreliminaryphasewiththewholeimplementationusedtondthebestlinking

onstraints, wean imagine an optimized ompilation through glue ode whih neither inludes brokersnor

managers.

5.5. Results. Werealized asenariowithanew omponentwhose onlyobjetiveis to usethebasi

re-souresMemoryandNetwork. ThisTestComponentprovidesonlythefoobarfuntionattoplevel. This

fun-tionhastwoimplementationlevels,andrequirestwofuntions:SreenMemory.amalloandNetwork.get. The

wholeappliation providesfourfuntionsat toplevel: TestC.foobar,ImageViewer.donext(anddoprevious)

and ImageSreen.displayimage. Three ontratsare negotiated, in thefollowing importane order: foobar

rst,thendonextanddoprevious,thendisplayimage.Wemadethethreeontratsanddownloadand

visual-izeimagesatthehighestqualities,butatsomepointthefoobarfuntionausesthedegradationoftheontrat

fordisplayimage,andtheimagesarethenshowninadegradedversion,liketheEieltoweronFigure5.1.

Thegap betweentheharateristisoftheontratandtheeetiveresoureusageanbemakethrough

(11)

Fig.5.4. Memoryuse

6. Related works. Other works also propose to use a developmentframework to handle resoure

vari-ability. In[10℄ and[6℄,theauthorproposeamodel-basedframeworkfordeveloppingself-adaptativeprograms.

Thisapproahuseshigh-levelspeiationsbasedontemporallogiformulatogenerateprogrammonitors. At

runtime,thesemonitorsaththesystemeventsandativatesthereonguration. Thisapproahissimilarto

usexeptthatitmainlydealswithhybridautomataandthereisnonotionofontratdegradationnorgeneri

algorithmfornegoiation.

Theexpressionandmaintenaneofresoureonstraintsisalsoonsideredasafundamental issue,somuh

workdealswiththissubjet. In[5℄,theauthoruseaprobabilistiapproahtoevaluatetheresoureonsumed

bytheprogrampaths. Someotherworksinthedomainofveriationtrytoproveonformaneofoneprogram

to somespeiation: in [7℄, forinstane, theauthors usesynhronousobserversto enode and verify logial

time ontrats. At last, the QMLlanguage ( [2℄, [1℄) is now well used to express QoSproperties. This last

approah isomplementaryto our onesine itprovidesalanguagewhih ouldbeompiled into soureode

forQoSComponentsorBrokers.

7. Conlusion and future work. In this paper, we have presented a ase study using the software

arhitetureQinnawhihwasdesignedtohandleresoureonstraintsduringthedevelopmentandtheexeution

ofembeddedprograms. Wefousedmainlyonthedevelopmentpart,bygivingageneraldevelopmentshemeto

useQinna,andillustratingitonaasestudy. Theresultingappliationisaresoure-awareappliation,whose

resouresonstraintsareguaranteedatruntime,andwhoseadaptationtovariabilityofservieisautomatially

doneby theQinna omponents, throughthe notionof ontrats. Atlast, weare ableto evaluate atruntime

thethresholdbetweenontratualisedresoureandtherealamountofresoureeetivelyused.

ThisworkhasshowntheeetivityofQinnawithrespettotheprogrammingeort,andtheperformane

ofthemodiedappliation.

FutureworkinludesomeimprovementsofQinna'sC++omponents,mainlyondatastrutures,in order

todereasetheglobalostofQinnaintermsofbinarysize,andmorespeianddetailedresoureomponents,

in orderto bettert totheplatform speiations. IntegratingQinnainto amodeldrivendevelopmenttools,

suh asGaspard([8℄),anbeawaytoimprovethiseieny.

From thetheoretialpoint ofview,there is alsoaneedfor awayto managethe linking onstraints. The

developerhasstilltolinktheimplementationlevelsofrequiredandprovidedservies,andtheorderbetweenall

implementationslevelsisxedbyhimaswell. Thetuningofalltheselinksanonlybedonethoughsimulation

yet. Wethinkthat somemethods likeontrollersynthesis([4℄) ouldbeusedto disoverthe/aoptimalorder

andlinkingrelationsw.r.t. someonstraintssuhasminimalvariability,bestreativityet..

Finally, sometheoretialwork would beneessaryin orderto useQinnaasapreditiontool,andprovide

aneientompilationintoglueode.

REFERENCES

[1℄ S.FrølundandJ.Koistinen,Qml: Alanguageforqualityofserviespeiation,teh.rep.,HPL-98-10,1998.

(12)

[3℄ L.GonnordandJ.-P.Babau,QuantityofResourePropertiesExpressionandRuntimeAssuraneforEmbeddedSystems,

inACS/IEEEInternational Confereneon ComputerSystems andAppliations, AICCSA'09, Rabbat, Moroo, May

2009,pp.428435.

[4℄ F.M.K.Altisen,A.ClodiandE.Rutten,Usingontrollersynthesistobuildproperty-enforinglayers,inEuropean

SymposiumonProgramming(ESOP),April2003.

[5℄ H. Koziolek and V. Firus, Parametri Performane Contrats: Non-Markovian Loop Modelling and anExperimental

Evaluation,inFormalFoundationsofEmbeddedSoftwareandComponent-BasedSoftwareArhitetures(FESCA),

Ele-tronialNotesinComputerSiene,Vienna,Austria,2006.

[6℄ I. Lee,S. Kannan, M.Kim, O. Sokolsky, and M.Viswanathan, Runtimeassurane based onformal speiations,

inProeedings of the International Conferene on Parallel and Distributed Proessing Tehniques and Appliations

(IPDPS'99),1999.

[7℄ F.MaraninhiandL.Morel,Logial-timeontratsforreativeembeddedomponents,in30thEUROMICROConferene

onComponent-BasedSoftwareEngineeringTrak,ECBSE'04,Rennes,Frane,Aug.2004.

[8℄ I.-R.Quadri,S. Meftali,andJ.-L. Dekeyser,Anmdeapproahforimplementingpartialdynamireonguration in

fpgas,inProeedingsofthe16thInternationalConfereneonIP-BasedSystem-on-hip,Grenoble,Frane,2007.

[9℄ M.Sparling,Lessonslearnedthroughsixyearsofomponent-based development,Commun.ACM,43(2000).

[10℄ L. Tan, Model-based self-monitoring embedded systems with temporal logi speiations, in Proeedings of the 20th

IEEE/ACMInternationalConfereneonAutomatedSoftwareEngineering(ASE'05),2005.

[11℄ J.-C.Tournier,Qinna: unearhitetureà basede omposantspourlagestionde laqualitédeserviedans lessystèmes

embarquésmobiles,PhDthesis,INSA-Lyon,2005.

[12℄ J.-C.Tournier, V.Olive,andJ.-P.Babau,TowardsadynamimanagementofQoSonstraintsinembedded systems,

inWorkshopQoSCBSE,inonjuntionwithADA'03,Toulouse,Frane,June2003.

Editedby: JanuszZalewski

Reeived: September30,2009

References

Related documents

1 Spatial planning of public charging points using multi-dimensional analysis of early adopters of electric vehicles for a city region..

In this study, it is aimed to develop the Science Education Peer Comparison Scale (SEPCS) in order to measure the comparison of Science Education students'

[r]

How the study was conducted The researchers used a 3-D global atmospheric download to predict how the radioactive material download move over earth and a health-effects model to see

contrast to the earlier waves of inter-ethnic violence that Devi’s novel depicts, ‘what was strange about the violence of 1968’, Jean Houbert remarks, ‘was that it was

Quality: We measure quality (Q in our formal model) by observing the average number of citations received by a scientist for all the papers he or she published in a given

commitment to you for Quality Assurance &amp; Project Management you will receive a call every week to go through the prior week’s inbound report. In these sessions, we will be

This article presents a framework and industry best practices allowing for the definition of usable metrics and intelligence that employ all the available operational