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.7. Summary 97<br />

A<br />

D<br />

E<br />

e<br />

e<br />

B<br />

C<br />

F<br />

e<br />

G<br />

(a)<br />

J<br />

H<br />

e<br />

K<br />

source constellation<br />

(initial state)<br />

Root<br />

A C<br />

D F<br />

H<br />

Root(A(D)|C(F|H))<br />

Root<br />

event e B<br />

C<br />

(b)<br />

target consteallation<br />

(after occurrence of e)<br />

G J<br />

K<br />

Root(B|C(G|J(K)))<br />

Figure 5.12: Determining the transitions to fire in a state machine step. The state<br />

machine depicted in (a) starts in its the initial constellation and e is<br />

the next event from the queue. Transitions originating in A, F , and<br />

H are selected <strong>for</strong> firing. The transition from D is skipped as transitions<br />

higher in the hierarchy take precedence. In a non-concurrent<br />

state machine at most one transition can fire. If multiple transitions<br />

fire, they can do so in any order.<br />

state and their values are retained during the transition, rather then deleting the<br />

variables and creating new instances.<br />

Note that on a particular hierarchy level, a non-concurrent state machine can<br />

only assume one state at a time. Hence, only the variables of this current state<br />

are active. Variables of mutually exclusive states on the same level can then<br />

be allocated to overlapping memory regions in order to optimize memory consumption<br />

(see Sect. 6.1.1).<br />

By embedding a set of parallel machines into a superstate, actions in different<br />

parallel state machines may access a variable of the superstate concurrently<br />

during the same state machine step at the same discrete time. This is no problem<br />

as long as there is at most one concurrent write access. If there are multiple<br />

concurrent write accesses, these accesses may have to be synchronized in some<br />

way. Due to the run-to-completion semantics of actions, a single write access<br />

will always completely execute be<strong>for</strong>e the next write access can occur. However,<br />

the order in which write accesses are executed (in the real-time model) is<br />

arbitrary and may lead to race conditions. Write synchronization is up to the<br />

programmer.<br />

5.7 Summary<br />

In this chapter we have in<strong>for</strong>mally presented OSM, a programming model <strong>for</strong><br />

resource constrained sensor-nodes. OSM is an extension of the event-driven<br />

programming model, adding two main features to the popular programming<br />

model: firstly, an explicit abstraction of program state as well as mechanisms to

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

Saved successfully!

Ooh no, something went wrong!