Distributed simulation of timed petri nets - IEEE Concurrency [see also ...

7 downloads 18691 Views 877KB Size Report
TI" niodcl for coinplex cellular network using a dedicated ... simulation of such networks exhibits good performance-for ..... cnd of ihr GI'T updatc prutocul. T.,ach.
Roberto Beraldi and Libero Nigro Unrveruta della Calabrra

Distributed Simulation of Timed Petri Nets

@ This modular and actor-based approach to the development of time-dependent

A Modular Approach Using

distributed systems separates functional

Actors and Time Warp

aspects from timing. The Time-Warp

-

mechanism regulates

his work focuses on using a modular and actor-based framework' ' t o develop distributed and time-dependent systemsE 1 both real-time and simulated. Our approach is modular in that 1 4 it specifies and handles functional and timing requirements ~eparately.~ For example, application actors remain unaware of timing *ap.

the interaction policy

,:

among logical

(

processes, shifting overhead from

constraints-that is, when and why mcssages activate thcm. They provide filnctional responses to messages belonging to a given message interface. 'liming issues fall to reflective actors that transparently filter message transmissions within groqis of actors, applying timing clanses that ultimately affect scheduling. Our approach favors olijcct reusability and proves useful both for dcveloping hard real-time systctns' and for supporting general distrihuted discrete-event simulation.5 In this article, we specialize our actor model to the distrilinted sirnulation of timed Petrinea, or'II'Ns,usingTime Watp.6Thc resultant architechue slipportsdifferent tiningrnodcls and enabling and fitingstrategies. Our Time-Warp mechanism ininimizs the communication overhead during rollbacks, and we can nmc it to model pamtioning and loadbalancingfor gnodperfnnnancein a heterogeneous, disailmted Wc also describe our development of a

communication to computation.

~~

52

,

~

~

test bed for our simulation framework, a

TI" niodcl for coinplex cellular network using a dedicated and homogeneous distributcd system of Kisc6000 workstations connected by a Fast Ethcr11etLAN.'~~~~00ur simulation of such networks exhibits good performance-for example, a speedup factor of 8 with 10 proccssors.

An actor model for time-

dependent systems ?Be variant of the Actor modell that we n s ~ D A R T J - w a s designed forthe development of dismibuted and time-dependent systems. By this modcl, a systein consists of a collection of subsystems, one per processor, interconnected through a possihly detcrministiccommunicationssystem. Each subsystem hosts a control machine, a scheduler actor, and a set of application actors. l b e disciplineof programming iti-the-large often suggests that only one administrator

~~~

~002-10~1~~91$iii.iio @ I Y Y ~reicii

IEEE Concurrency

Acronyms and abbreviations DART FIFO GSPN GW

actvr should lie referenced a t the system level. 'l'his adiiiinistrator actor receives message requests and can delepte its processing to itiner snhsysterii actors. In a SCIISC, the administrator represents the sohsystem. The control machine Iirovidcs the necessary support for scheduling, message sclcction, and message dispatch.

ACTORS Actors are the basic Irnilding blocks illthe-sinall. We can think vf a n actor as a finite-state machine that evolves through a life cycle-that is, a succession of states orlichavivcs. An actor is areactive object, reqmiding to incoming messages on the hasis of its current state and messagc coiltent. Message reception is implicit-that is, there is no receive primitive. An actor the cxeciilion of an actim. Because action execution is atomic, it c empted or sospcndcd. M unexpected tu an actor in its current state. An actor can postpone processing such Inessages hy rerncmbcring them in local data or in states uf the life cycle. llasic operations un DART actors arc mw, which creates a new actor, becmnc, which changes the actor's state, and smd, hy which a n actor transmits iiiessages to acquaintance actors (incloding itself) in a nonblocking way.

DART differs from the standard Actor model' i n scvcral ways:

-

Its actors have no intcmal thread. DART actors are instances of a passive class that directlyor indircctly extends die Actor lrasc class. The actors' life cycles come froni a message handler that thc contrvl machine invokes at messagc dispatch time. It does not include a imail qocue pcr actor. Rathcr, thc control machitie introduces a single message queue upon which it schedules, selccts, and dispatches sent messages according to a nrooer control strnctore. l'hesourcc nfconcurrc,icyamn~,nb!actorsinasinglcsubs~tcmisactionintcr-

leaving cnsnrcd Iiy the coiit~~il-tnacliine dispatching scheme. Concurrency among actors allucated to differcnt processors is tmc parallelism.

IQ LP LW GW MAC MNSV

04 PCS PVM SPEEDES

Distributed Architecture for Real Time first-in, first-out generalized stochastic Petri nets global virtual time input queue logical process local virtual time global virtual time modified aggressive cancellation maximum number of stored versions output queue personal communications sewices parallel virtual machine Synchronous Parallel Environment for Emulation and Discrete-EventSimulation rtochastic Petri nets state save rate stateversions time basic (Petri nets) timed Petri nets Time-Warp control engine

Bcsidcs actvrs, thc architecture also allows SPN for the cxistencc ofpasSSR sive objects that don't SV have a life cycle. l'he TB system invokes their TPN mcthvrls s ~ ~ c h r o n o u s TWCE Iy hy the usual procedure-call sciiiaiitics. Bccansc of the atnniic characicr vl'action execution in actors, passive olljects belxive naturally as nionitors, so thcrr is no need for conventiuiial tnotual-exclusion primitives (semaphorcs and dcrivatives).The system ctinld also include an actor to export accessor inetliods that can hc rcqucstcd synchronously instcad of by message passing.

REFLECI.ION AND c o m o ~ . MACHINE 'l'lie actors' dynamic behavior depends on a cmtrol discipline adopted at the colitrol-machine level. Hem, the control

siriictwc can hc purely event-driven as in the actor model, which is useful for concurrent applications; it caiilic purely dmedriven tvsuithard real-tiinesystems; or it can be a coinbinationofthc two. Thc control machinc relies on the concept of rcflcctioii.I(' It can rcasiin in a tiinc diinensioii and Control machine be causally connected with applicadvn actvrs. As shown in Vigore 1, thc hasic compvnents Scheduler of a control machine are

I

theclock, the message queue (a priority queue uscd as a calendar or event list), the controller, and

* the I"ogrammcr-dctincr1 actor.

schcdulcr

At initialization, the contrul niachine is fed a p"rticu1ar schcdulcr. The timc notion call bc virhial or rcd. In n simple case, each message comes along with a t i m e stamp indicating ihc occurrcncc tiinc o l thc cvent captured by thc mcssagc. In general, for real-time applications, a incssage conics accoinpanied by a validity time window-[Linin, tinax]that specifiespossihle delivery times.z,J [,et's focus here on virtual time only a n d a stand-alone simulation control machine. 'lhis system attaches a time stamp to each mcssagc. Thc controllcr mcthod is equipped with the maximum

Message queue

1

I

Controller

1

Subsystem

actors

~~~

3ure 1. Organization of a sequential-simulation control machine ~

October-December 1999

53

simulation time. It repeats a basic control loop-a sequential simulation engine. At each iteration, the controller method selects the message with the earliest time stamp from the message queue and uses its time stamp to adjust the simulation clock; delivers the message to its target actor by invoking the relevant message handler, which in hirn causes a state switch and triggers cxecution of an action; and upon the action’scompletion, resumes the control loop and gives the scheduler a chance to schedule the just-sent messages. T h e loop repeats until the virtual timc cxcceds the maximum simulation time or until the simulation dcadlocks. It is worth noting that the basic send operation annotates the just-sent messages in a temporary qneue in the actor base class. T h e scheduler’s message handler takes charge ofschedolingthese messages in the control-machine message queue. W e specify the time behavior of subsystem actors separately from actor fimctional behavior in a scheduler actor that knows appliation time requirements. Our model offers the following interfacc for programming a scheduler: msg.cume() rcturns theidentity ofthe message whose processing generated msg. msg.iTime( ) returns the dispatch time of a message. schedule(msg, timestamp) schedules msg on the message queue hy attacliing a time stamp to it. 54

dcschedule(msg, timestamp) removes a previously scheduled message from the messagc queue. no7u( ) returns the current time. A scheduler hosts a set of time clauses-that is, it implements a set of RTsynchronkrs (see the “Previoos work” sidebar). T o exemplify the expression of timing coiistraints, let’s consider a cyclic actor of the Source class, which understands messages of the Generate class. To sustain a generation process, the actor continually sends a Generate message instancc to itself. T h e time stamp of the rncssage can he defined by an exponential randoin variate. T h e following is a possible time clause for schcduling such a message using Java syntax:

regulates the evolution of a snbsystem’s actors. Although thc application actors are programmed according to the eventdrivcn paradigm, the resulting behavior can be time sensitive as established by the scheduler and control machine. T h e controllers of a set of distributed control machines can cooperate to fillfill system-wide synchronization constraints. T o this purpose, they can rely on a limited set of control mcssages hidden from application actors. A key factor of the DART approach is a smooth transition from the evcntdriven to the time-driven paradigm, with application actors that remain unaware of the specific control discipline enforced by tlm control machine. This also favors modularity, because it lets us reuse actors to fit different application requirements. With an object-oriented language such as Oberon-2, Ccc, or Java, we can effectively program the control macliinc and schcduler actor using the basic mechanisms of dynamic binding, polymorphism, and rimtime type identification. T h e resulting actor programming style is safe, clean, and s0und.l

Distributed simulation and Time Warp Tll,then tissaidto bemuitiply enabled at degree c. if tcan fireonly oneenabling a t a time, it adopts the single-serverremantics.Infinite sewer semantics occurs when any amount of enabling8 can be fired at one time, expressing a notion of parallelism among them. There are a variety of different firing rules defined upon TPNs."intheSPN class,forexampie, transition firing isatomic. Arandom timeelapses between theenabling and thefiring of a transition tj, during which the enabling tokens reside in the input places. Transition t, must be continuously enabled during the time zk and it fires at that time: this isthe race or preemptive policy. Another execution rule for TPNs occurs when an enabled transition fires in three phases: in a "start firing" phase, tokens are removed from the input places. remaining invisible fora "firing in progress" phase until they are released into output places in the "end firing" phase. This is the preselection or nonpreemptive policy.

P = b,, p2, ..., p,$ is a finite set of Pelements. or places. Teiements, ortransitions, withPnT=0andanonemptysetofnodes,PuT#01. * FE (Px u(TxP) is afinitesetof arcs between Pelements and Telements. * W,F - 1 N assigns weights w(0 t o elements of f t Fdenoting the multiplicity of unary arcs between the connecied References nodes. 1. T. Murata, "Petri Nets: Propenies, Analy~isand Applications,'' n: T-lNassignsprioritiesxjtoTelementsttt T. Pror. IEEE, Vol. 77. No. 4, 1989, pp. 541-580. * z: T+%asrignsfiringdelayst,toTelementst,~ T. 2. C. Ghezzi et al., "A Unified High-Lwei Petri Net Formalism for M:P-tN+~isthemarking/~~~J=~jl~~J@;)ofPelementsp,t P. Time-CriticalSystems," IEEE Tram Software Engineering, Vol. 17.No.2,Feb. 1991,pp. 160-172. There are three important cases of firing delays: 3. G.Chioiaetai., "GeneraliiedStacharticPetri Netr:ADefinition * immediate transitions, when t, = 0, a t Net Level and Its Implicationr." IEEE Trans. Software Engideterministic timed transitions, when r, t % is a deterneering, Vol. 19. No.2, 1993, pp.89-107. ministic time value, and 4. A. Ferrcha, "Concurrent Execution of Timed Petri Nets,'' Proc. * stochastic timed transitions, when t j i s an instance of a 1994 WinterSirnulation Conf., IEEE P~e16,Pircataway. N.J.. 1994, random variable? pp. 229-236.

* T=(t,, ,t ..., t,,)isafinitesetof

n

I t is pnssililc to instrument tlic cxccu-

of a TlW modcl on a single niaciiinc-this is called sequential sitin-

I)Al~l'-ccntcred, iriodnlar apprciach fur tlic clistrihuted excciiLioii and siiiiulntion of Tl'Ns.

lation. However, LO aiiiiilatc camplex systems, panillel or disttibutcd siniulaLionarc prrfcrable.'n Next, wc p s c i i t ; i

Lition a TPN iiiodcl into scvcral regions so that conflicting transitions togetlicr

tim

Tu iinprove performince, we can par-

with all their input plnccs rcside in tlic saiiie Lll.5 An olwious iiiapping d ' I l W s un our Tiiuc-Waqi architecture woiild b e to associate distinct ;ictors to transitions a n d places of a 'L'I'N, w i t h a i l i n i t i a l -

October-Decem ber 1399

57

allow for the configuration ofcoarsegrained regions adcqnatc h r a distribntcd system of standard workstations;

minimize the number of exchanged messages, a critical factor for the simulation of complex systems; and facilitate tlie region's (LP) statits saving-and-restoring operations ncccssary to the Time-Warp niechauisni. For each LP, we intradnce a region actor initialized with a passive data structure dcscrihing the rcginn t n p n ogy (see Figore 3). T h e region implements the functional T P N execution model. T h e internal statiis of a rcgion actor includes a mnlti?zgvector that has a n cntiy for cach place in thc rcgion, a n enabliqvector that has a n entry for each transition in the region, and afiri?zpcctor that rcgistcrs the histnry of transition firings for statistical data collection, Ainai-king entiy simply stores the nmnher of tokens present in the associated place. AI, enabling entry stores the mmher of available enablings for tlie associated transition. This can he zero if the transition is disabled or a value cif the transitinn is multiply cna1,lcd with degree c. A inerarcgion actor is fed transition attributes-that is, the mean nfthc exponential distrihution function for timed

were influenced by the firing oft. It generates a corresponding group of trimrition_~;~~/s71fil.e messages on the basis of variations between old a n d new valuer of cnahlings.

A rcgion proccsscs a toke?z_ar-rivnl message using stcps similar to the marking update (step 2) and tlie enabling npdate (step 3). T h c mctarcgion schcdules iintitncd wtinsitionj i v e message according to wansition priority, or nondeteriiiiuistically if synergic tandem. Tlicy r i m s t agrcc on tlic priority is tlie same. It noruially some fun~latneiiwlpuine, such as whether schedules timed transitionfire uicssagcs they will use prccniptinn or prcsclcction according to the transition's next-sample as the strategy regulating transition tire time, determined throogh a n expoenabling and tiring. Icor generality, we nential variate generator. Undcr prcsclection, tlic rnctarcgion adopt hy dcLdt the infinite-sewer S ~ X tics for transition firing. Ifwe needed sin- performs a preliminary railking of the gle-server semantics,wc could add to each jiast-scnt tiwnsitioizfilr messages on the transition a loop-hack place with a single basis ofttansition attributcs; it tentatively assigntlcd tnkcn. schcdulcs thcm according to this order. I~ollnwingthe firing of a transition t, IIowever, it acnially schcdulcs a wmithc rcginn actor, undcr racc cnnditims, timi& mcssagc provided it has not heen iniist identify the set of transitions that disabled by a previously schcdolcd wunhave increased their enablings and the set sitionfire. If the transition is still enabled, of transitions that have lost some the inetaregion first removes its enabling enablings. For each new enabling or dis- tuple from its preset and considers its firabling, tlic rcginn gcncratcs and sends to ing cnmmittcil. If the transition has heen itself a distinct t~nn~itin?zfi7.e/zinfr,.e mes- disabled, the inetaregion simply abansage with the associatcd transition as a dons tlie warxitionfire message. parameter. Under preemption, conflicts T