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
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
34 Chapter 3. <strong>Programming</strong> and Runtime Environments<br />
work failures. However, immanent bugs in the nodes’ system software may<br />
lead to system crashes that may render an entire WSN useless. Particularly if<br />
many or all nodes of the network run identical software or if cluster heads are<br />
affected, the network may not recover.<br />
<strong>Programming</strong> frameworks <strong>for</strong> sensor nodes should support application designers<br />
in the specification of reliable and, if possible, verifiable programs. Some<br />
of the standard programming mechanisms, like dynamic memory management<br />
and multi-threading, are known to be hard to handle and error prone. There<strong>for</strong>e<br />
some programming frameworks deliberately choose not to offer these services<br />
to the application programmer.<br />
3.1.3 Reactivity<br />
The main application of WSNs is monitoring the real world. There<strong>for</strong>e sensor<br />
nodes need to be able to detect events in the physical environment and to react<br />
to them appropriately. Also, due to the tight collaboration of the multiple<br />
nodes of a WSN, nodes need to react to network messages from other nodes.<br />
Finally, sensor nodes need to be able to react to a variety of internal events, such<br />
as timeouts from the real-time clock, interrupts generated by sensors, or low<br />
battery indications.<br />
In many respects sensor nodes are reactive systems. Reactive systems are computer<br />
systems that are mainly driven by events. Their progress as a computer<br />
system depends on external and internal events, which may occur unpredictably<br />
and unexpectedly at any time, in almost any order, and at any rate. Indeed, the<br />
philosophy of sensor-node programming frameworks mandates that computations<br />
are only per<strong>for</strong>med in reaction to events and that the node remains in sleep<br />
mode otherwise in order to conserve power.<br />
On the occurrence of events, wireless sensor nodes react by per<strong>for</strong>ming computations<br />
or by sending back stimuli, <strong>for</strong> example, through actuators or by sending<br />
radio messages. <strong>Sensor</strong> nodes need to be able to react to all events, no matter<br />
when and in which order they occur. Typically reactions to events must be<br />
prompt, that is, they must not be delayed arbitrarily. The reactions to events<br />
may also have real-time requirements. Since the handling of events is one of<br />
the main tasks of a sensor node, programming frameworks <strong>for</strong> sensor nodes<br />
should provide expressive abstractions <strong>for</strong> the specification of events and their<br />
reactions.<br />
3.2 <strong>Programming</strong> <strong>Model</strong>s<br />
<strong>Sensor</strong> nodes are reactive systems. Programs follow a seemingly simple pattern:<br />
they remain in sleep mode until some event occurs, on which they weak<br />
up to react by per<strong>for</strong>ming a short computation, only to return to sleep mode<br />
again. Three programming models have been proposed to support this pattern<br />
while meeting the requirements specified previously. These models are<br />
the event-driven model, the multi-threaded model, and the control-loop model.<br />
The event-driven model is based on the event-action paradigm, while the multithreaded<br />
model and the control loop are based on polling <strong>for</strong> events (in a block-