文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 计算机软件及应用 > Design and implementation of Triveni A process-algebraic API for threads + events
侵权投诉

Design and implementation of Triveni A process-algebraic API for threads + events

We describe Triveni, a framework and API for integrating threads and events. The design of Triveni is based on an algebra, including preemption combinators, of processes. Triveni is compatible with existing threads standards, such as Pthreads and Java thre

illustratesthetechniqueofpreemptingaprocesstoestab-lishprioritiesonevents—theeventsand

havehigherprioritythantheeventsoccur-ringintheabove.Onreceiptofevent,aprocessentersaloopthatmonitorsthestatusoftheof cedoor.Thein-variantuponentrytotheloopisthattheof cehasjustbeenplacedineconomymodeandneedstobeputtosleep.

While

isbeingemitted,thecombinatorwaitsuntiloccurs.Inthecasethatarriveswhiletheemissionofisstillpending,theemissionisabortedviathe/combinatortoensurecon-sistency.Whenthedoorbecomesopen,asymmetricpro-cessemitsandwaitsfor.Onreceiptof,thedoor-monitoringloopispreemptedandtheof cereturnstooccupantmode.Thecodehandles

thepossibilitythat

willarrivewhileisstillpending.

economy_control:

templast_temp=INITIAL_TARGET_TEMP;

tempeconomy;

LOOP

RequestTemp(t)->{last_temp=t;}DONE||

LOOP

EconomyMode(t)->{economy=t;}DO

LOOP

DOEMITSleepWATCHINGDoorOpen||AWAITDoorOpen->

DOEMITAwakeWATCHINGDoorClose||AWAITDoorClose->DONE

WATCHINGOccupantMode||

LOOP

OccupantMode->DO

EMITAwake(last_temp)WATCHINGEconomyMode

Nowwebuildanof cecontrolprocessfroman

occupant-controlprocessandaneconomy-controlpro-cess.Notethattheoccupant-controlprocessmustbedisabledduringeconomymode.Thisisdonewiththe

/combinator,whichsuspendsaprocess

onreceiptofaspeci edevent(inthiscase)and

resumesitonanotherevent(

inthiscase).Thus,whenevertheeconomycontrolsendsaevent,theoccupantwilllosecontrolofthelightandheatuntilthe

economycontrolsendsan

event.Twoprocesses(notshowninthepicture)runinparallelwiththeoccupantcontrolandtheeconomycontroltoadjustthelightandheatappropriatelywhenevertheof cetogglesmodes;eachpre-emptstheothertoavoidinconsistency.Notethatparallel

compositionautomaticallyroutes

eventstobothsubprocessesthatacceptthem.

of cecontrol

SwitchOnSetTemp(t)SwitchOff

occupantcontrolLightOnsuspend

resume

LightOff

RequestTemp(t)

Sleep(t)Awake(t)

DoorOpeneconomycontrol

DoorClose

EconomyMode(t)OccupantMode

office_control:

occupant_controloc;

economy_controlec;

LOCALSleepAwakeIN

ec

||ocSUSPENDSleepRESUMEAwake||LOOP

Sleep(t)->DOEMITSetTemp(t)

||EMITLightOffWATCHINGAwake

||LOOP

Awake(t)->DOEMITSetTemp(t)

WATCHINGSleep

Theof cecontrolisrathercomplex,andsowemaywanttosprinkleinsometemporalsafetypropertiestobecheckedduringexecution.Forinstance,usingde nitions

-

where-meansthatneveroccurred(i.e.,an

of ceisinitiallyawake),wede nethefollowingpropertytospecifythebehaviorofthelight:

Thisspeci esthatwheneveroccurs,boththeof- cemustbeawake(nosincethelast)and

theswitchmustbeon(de nedsimilarly).Also,when-ever

occurs,eithertheof cemustbeasleeportheswitchmustbeoff.NotethatXORis

atautology,butthatthisisnotquitetrueof

XORbecauseneithernoristrueduringan

executionuntilthe rstorevent.Tocompletetheimplementationofasingleof ce,wecomposeatemperature-stableof cewithanof cecontrol.Theresultingof ceprocessemitsnoeventsandaccepts

onlyevents

and.Thecombinatorhidesallotherevents.

上一页第4页

你可能喜欢

热门文档

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email