21.08.2013 Views

A State-Based Programming Model for Wireless Sensor Networks

A State-Based Programming Model for Wireless Sensor Networks

A State-Based Programming Model for Wireless Sensor Networks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.5. Hierarchical Composition 91<br />

state B, lifetime varB<br />

state B’, lifetime varB’<br />

inB() inB’() outB()<br />

f<br />

outB’()<br />

real time<br />

0 1<br />

2 discrete time<br />

Figure 5.7: Possible mapping of real-time to discrete time <strong>for</strong> parallel machines.<br />

of OSM operates on sets of concurrent events rather than on individual events.<br />

All elements of a set are handled in the same discrete state-machine step. The<br />

enqueue operation takes a set of concurrent events as a parameter and appends<br />

this set as a whole to the end of the queue. The dequeue operation removes the<br />

set of concurrent events from the queue that has been inserted earliest. Whenever<br />

the system is ready to make a transition, it uses the dequeue operation to<br />

determine the one or more events to trigger transitions.<br />

All events emitted programmatically in exit and entry actions, respectively,<br />

are enqueued as separate sets of events, even though they are emitted during<br />

the same state machine step. That is, each state-machine step consumes one set<br />

of events, and may generate up to two new sets: one <strong>for</strong> events emitted in exit<br />

actions and another set <strong>for</strong> events emitted in entry actions. Clearly, the arrival<br />

rate of event sets must not be larger than the actual service rate, which is the<br />

responsibility of the programmer.<br />

5.4.2 Progress in Parallel Machines<br />

The execution semantics of a set of parallel state machines can now be described<br />

as follows. At the beginning of each state-machine step, the earliest set of concurrent<br />

events is dequeued unless the queue is empty. Each of the parallel state<br />

machines considers the set of dequeued (concurrent) events separately to derive<br />

a set of possible transitions. Individual events may also trigger transitions<br />

in multiple state machines. Similarly, if multiple concurrent events are available,<br />

multiple transitions could fire in a single state machine. To resolve such<br />

ambiguous cases, priorities must be assigned to transitions. Only the transition<br />

with the highest priority is triggered in each state machine. Actions are executed<br />

as described in Sect. 5.3. The dequeued set of concurrent events is then dropped.<br />

5.5 Hierarchical Composition<br />

Another important abstraction supported by OSM are state hierarchies, where<br />

a single state (i.e., a superstate) is further refined by embedding another state,<br />

state machine (as depicted in Fig. 5.8 (a)) or multiple, concurrent state machines<br />

(as depicted in Fig. 5.8 (b)). Just as uncomposed states, superstates can have<br />

state variables, can be source or target of a transition, and can have entry and

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!