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.

3.4. Process <strong>Model</strong>s 49<br />

can not rely on any particular order as it depends on the actual implementation<br />

of the event-scheduling mechanism. In actual systems, the execution order of<br />

actions of separate processes is typically arbitrary.<br />

The answer to the second question—how long can actions be delayed?— may<br />

be important when applications have real-time constraints. The answer depends<br />

on the execution times of actions from the different programs running concurrently<br />

and can there<strong>for</strong>e not be answered easily by any single application developer.<br />

From our experience with the event-driven model it is already hard<br />

to analyze the timing dependencies in a single application without appropriate<br />

real-time mechanisms. In a concurrent execution environment, where no single<br />

application programmer has the entire timing in<strong>for</strong>mation, timing estimates are<br />

even harder to get by. There<strong>for</strong>e, concurrent process models based on events can<br />

decrease the systems reliability. Since almost all application have at least some<br />

moderate real-time constraints, we believe that process concurrency should be<br />

avoided on event-driven sensor nodes.<br />

Note that a question similar to the second (i.e., how long can the invocation<br />

of an action be delayed?) also arises in multi-treading environments. For such<br />

environments the re<strong>for</strong>mulated question is: how much slower can the program<br />

become with multiple threads running concurrently. In multi-treading environments<br />

the execution delay of operations only depend on the own application<br />

code and the number of programs running concurrently, not the contents (i.e.,<br />

the code) of other programs. For example, in the simple round-robin scheduling,<br />

the CPU time is equally divided among threads. If n threads are running, each<br />

thread is allocated to the CPU <strong>for</strong> the length of a time slice be<strong>for</strong>e having to wait<br />

<strong>for</strong> another n − 1 time slices. There<strong>for</strong>e the execution speed is only 1/(n)-th of<br />

a system with only a single program executing. Actual implementations would<br />

be slower since context-switching consumes non-negligible time.<br />

3.4.5 Analysis of Process <strong>Model</strong>s<br />

Mainly because of potentially unresolvable resource conflicts there are several<br />

reliability issues with process concurrency in sensor networks, regardless if its<br />

implementation is based on context-switches or events.<br />

When appropriate mechanisms <strong>for</strong> inter-process protection are missing,<br />

which is the rule rather than the exception, a single deficient process can jeopardize<br />

the reliability of the entire system. Even without software bugs it is practically<br />

impossible to analyze in advance whether two concurrent processes will<br />

execute correctly. One problem is, that programs compete <strong>for</strong> resources in ways<br />

that cannot be anticipated by programmers. If one process requires access to<br />

exclusive resources, such as the radio or sensors, they may be locked by another<br />

process. Limited resources, such as memory and CPU time, may be unavailable<br />

in the required quantities. Identifying potential resource conflicts is<br />

very hard and fixing them with alternate control flows is practically infeasible.<br />

To make things worse, programmers of different applications typically cannot<br />

make arrangements on the timing of CPU intense computations and high resource<br />

usage. There<strong>for</strong>e there are typically innumerable ways how two processes<br />

can ruin each others assumptions, particularly in the face of slow and<br />

resource-constrained sensor nodes.

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

Saved successfully!

Ooh no, something went wrong!