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.

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

tive measures, special mechanisms <strong>for</strong> inter-process communication exist, like<br />

shared memory, message passing, and semaphores.<br />

The main objectives of process concurrency in general-purpose operating systems<br />

is to optimize processor utilization and usability (cf. [108]). While one<br />

process is waiting <strong>for</strong> an input or output operation to commence (e.g., writing<br />

a file to secondary storage or waiting <strong>for</strong> user input), another process can continue<br />

its execution. There<strong>for</strong>e some process is always running. From a user perspective,<br />

process concurrency can increase the systems usefulness and reactivity.<br />

Running several programs in parallel allows to share the processing power of a<br />

single computer among multiple users. To each of the users it appears as if they<br />

had their own (albeit slower) computer exclusively to them. Also, a single user<br />

running several applications can switch back and <strong>for</strong>th between them without<br />

having to terminate them.<br />

Context-switching sensor-node processes. In order to avoid the resource overhead<br />

induced by two layers of scheduling, context-switsched sensor-node operating<br />

systems typically only provide a single level of scheduling on the basis of<br />

threads. That is, threads are the only scheduled entity. This does not mean,<br />

however, that multi-threaded sensor-node operating systems cannot provide<br />

process concurrency. If they do, the threads of distinct processes are contextswitched,<br />

thereby also switching processes. Processes then consist of a collections<br />

of threads, which are indistinguishable from the threads of other processes.<br />

The notion of a process is entirely logical, denoting all threads belonging to a<br />

program. In simple implementations a fine-grained control mechanism over the<br />

CPU time assigned to processes is missing; a process with more threads may receive<br />

more CPU time. To dynamically create a new process, the binary image of<br />

the program (consisting of a collection of threads) is loaded and all of its threads<br />

are instantiated.<br />

Threads or tasks? In the face of a single level of context switching, the question<br />

my arise, why we consider the context-switched entities of sensor-node<br />

system software to be threads rather then processes. This seems to be a rather<br />

arbitrary, if not an unusual view, because in the history of modern operatingsystem<br />

development, support <strong>for</strong> concurrent processes (e.g., multi-tasking) was<br />

introduced well be<strong>for</strong>e concurrency within individual processes, as provided by<br />

multi-threading (cf. [27]). In fact, multi-threading was long missing in generalpurpose<br />

operating systems.<br />

Though threads and tasks are similar in several respects, they have been developed<br />

<strong>for</strong> different reasons and serve different objectives. While multi-tasking<br />

aims more at the user of the computer system, multi-threading is mainly an abstraction<br />

to aid programmers. In sensor networks, concurrency is mainly considered<br />

a tool <strong>for</strong> specifying reactive programs while supporting multiple processes<br />

or even multiple users is considered less important. Also, the context-switched<br />

entities in wireless sensor networks have much more in common with threads<br />

than processes, because of the way they share resources. Most of the measures<br />

to protect distinct processes found in traditional multi-tasking systems are not<br />

(and cannot be) implemented in sensor networks. Because of these reasons, the<br />

term task has become widely accepted in sensor-network literature to denote<br />

context-switched entities.

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

Saved successfully!

Ooh no, something went wrong!