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.

136 Chapter 7. <strong>State</strong>-based <strong>Programming</strong> in Practice<br />

only reduced by a small amount. Furthermore, CALIBRATION may be an only<br />

transient state itself. Then its (as well as its substate’s) memory resources would<br />

also reused once the state is left. Since CALIBRATION does not compute a result<br />

required in a subsequent state, no additional variables are needed.<br />

Since the OSM compiler compiles OSM program specifications back to regular<br />

event-driven code, one could also object that the mechanism of mapping<br />

variables to overlapping memory regions could also be used manually in the<br />

plain event-driven model. Though possible in principle, programmers would<br />

not only have to manage the program’s state machine manually. They would<br />

also have to manually map the states’ variables to the complex memory representation,<br />

such as the one shown in Prog. 6.5. Even minor changes to states high<br />

in the hierarchy, such as the addition or removal of a layer in the hierarchy, lead<br />

to major modifications of the memory layout. Consequentially, access to elements<br />

of the structure would also change with the structure, requiring changes<br />

throughout the program. There<strong>for</strong>e we think that our state-variable approach is<br />

only manageable with the help of a compiler.<br />

7.3.2 General Applicability and Efficiency<br />

Now two question arises: are state variables applicable to real-world sensornode<br />

programs? And, how much memory savings can we expect? We cannot<br />

answer these questions conclusively, as extensive application experience is missing.<br />

However, we have several indications from our own work with sensor-node<br />

programming as well as from descriptions of sensor-node algorithms in the literature<br />

that state variables are indeed useful.<br />

General Applicability of <strong>State</strong> Variables<br />

Probably the most-generally applicable example where sensor-node programs<br />

are structured into discrete phases of operation is initialization and setup versus<br />

regular operation of a sensor node. Typically sensor nodes need some <strong>for</strong>m<br />

of setup phase be<strong>for</strong>e they can engage in their regular operation mode. Often<br />

longer phases of regular operation regularly alternate with short setup phase.<br />

Both phases typically require some amount of temporary data that can be released<br />

once the phase is complete. Setup may involve assigning roles to individual<br />

nodes of the network [56, 98], setting up a network topology (such as<br />

spanning trees [84]), per<strong>for</strong>ming sensor calibration, and so on. Once setup is<br />

complete, the node engages in regular operation, which typically involves tasks<br />

like sampling local sensors, aggregating data, and <strong>for</strong>warding messages. Regular<br />

operation can also mean to per<strong>for</strong>m one out of several roles that has been<br />

assigned during setup. For the setup phase, temporary data may contain a list<br />

of neighboring nodes with an associated measure of link quality, node features,<br />

as well as other properties of the node <strong>for</strong> role assignment and topology setup.<br />

Or they may contain a series of local and remote sensor measurements <strong>for</strong> calibration<br />

(as in our previous example). For regular operation, such variables may<br />

contain aggregation data, messages to be <strong>for</strong>warded, and so on.

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

Saved successfully!

Ooh no, something went wrong!