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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6.2. OSM Language Mapping 107<br />

Adding Entry Actions and Transitions<br />

When incarnating a state, transitions, entry actions, exit actions, and preemption<br />

actions can be added to the original state definition. Adding transitions and actions<br />

to the original state definition is typically used when the program context<br />

of the incarnation is not known at implementation time. In Prog. 6.4, A is the<br />

incarnation of template I. In I there are no outgoing transitions defined. In I’s<br />

incarnation A, however, a transition is added leading from A to B (line 18). Also,<br />

an incoming action inA(u) is added to the transition from B back to A (line 17).<br />

Adding Preemption Actions<br />

When incarnating a state, preemption actions can be added to the original state<br />

definition. Preemption actions can be added to react to the termination of the<br />

incarnation’s superstate. Adding preemption actions is useful, <strong>for</strong> example, to<br />

include an existing stand-alone program as a sub-phase of a new, more complex<br />

program. In our example Prog. 6.4 there are no preemption actions added to the<br />

incarnations of either states, since their common superstate P ROG_4 is never<br />

left.<br />

6.2 OSM Language Mapping<br />

An OSM language mapping defines how OSM specifications are translated into<br />

a host language. The host language is also used <strong>for</strong> specifying actions. Such a<br />

mapping is implemented by an OSM compiler. For every host language, there<br />

must be at least one language mapping. Yet, there may be multiple mappings<br />

focusing on different aspects, such as optimizations of code size, RAM requirements,<br />

execution speed, and the like. We have developed a prototypical version<br />

of an OSM compiler that uses C as a host language. Hence, we discuss how<br />

OSM can be mapped to C in the following sections. The main goal of our compiler<br />

prototype is to create executable OSM programs that<br />

• have low and predictable memory requirements and<br />

• are executable on memory-efficient sensor-node operating systems.<br />

In general, OSM programmers do not need to know the details of how OSM<br />

programs are mapped to executable code. What they do need to know, however,<br />

is how actions in OSM are mapped to functions of the host language. Programmers<br />

need to provide implementations of all actions declared in OSM, and thus<br />

need to know their exact signature.<br />

Internally, and typically transparently to the developer, our compiler prototype<br />

maps the control structure and state variables of OSM programs separately.<br />

<strong>State</strong> variables are mapped to a static in-memory representation using<br />

C-language structs and unions. This mapping requires no dynamic memory<br />

management and is independent of the mapping of the control structure.<br />

Yet it is memory efficient, as state variables with non-overlapping lifetimes are<br />

mapped to overlapping memory regions. Also, the size of the in-memory representation<br />

of all state variables is determined at compile time.

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

Saved successfully!

Ooh no, something went wrong!