Research Article Supporting Preemptive Multitasking in Wireless Sensor Networks Emanuele Lattanzi, Valerio Freschi, and Alessandro Bogliolo Department of Basic Sciences and Foundations, University of Urbino, Piazza della Repubblica 13, 61029 Urbino, Italy Correspondence should be addressed to Emanuele Lattanzi; emanuele.lattanzi@uniurb.it Received 12 April 2013; Revised 19 December 2013; Accepted 20 December 2013; Published 6 February 2014 Academic Editor: Frank Ehlers Copyright © 2014 Emanuele Lattanzi et al. his is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited. Supporting the concurrent execution of multiple tasks on lightweight sensor nodes could enable the deployment of independent applications on a shared wireless sensor network, thus saving cost and time by exploiting infrastructures which are typically underutilized if dedicated to a single task. Existing approaches to wireless sensor network programming provide limited support to concurrency at the cost of reducing the generality and the expressiveness of the language adopted. his paper presents a java- compatible platform for wireless sensor networks which provides a thorough support to preemptive multitasking while allowing the programmers to write their applications in java. he proposed approach has been implemented and tested on top of VirtualSense, an ultra-low-power wireless sensor mote providing a java-compatible runtime environment. Performance and scalability of the solution are discussed in light of extensive experiments performed on representative benchmarks. 1. Introduction Multitasking is a method which allows multiple tasks to be concurrently performed in the same time period by a shared processing unit. In microprocessor systems, the scheduler of the operating system (OS) decides to which task the shared resources have to be assigned at any given time in order to maximize the overall throughput and meet the perfor- mance constraints of the applications. While multitasking is common practice in general-purpose computer systems, it is not commonly supported in wireless sensor networks (WSNs) made of lightweight nodes subject to tight power and resource constraints. On the other hand, the growing need for context aware- ness and ambient intelligence is rapidly pushing the deploy- ment of WSNs and the development of applications designed to run on top of them. Supporting the concurrent execution of multiple applications on a shared WSN is an attractive perspective in terms of cost sharing, deployment time, and sustainability. In principle, a multitasking WSN could be deployed once and for all in a given place and then made available to end users and sotware developers as a common platform to run any kind of context-aware applications, possibly focused on diferent physical quantities, targeting diferent portions of the network, and belonging to diferent users. his can be useful not only to deploy shared test beds allowing diferent research groups to run comparative experiments, but also to enable a thorough sharing of real world sensor networks among diferent users independently running their own tasks. For instance, a WSN equipped with CO 2 sensors could concurrently execute tasks to collect data about air quality, control HVAC equipment, trigger ire alarms, and estimate the number of people in a room. he applications could be independently developed by diferent users and dispatched to the same nodes. Such a scenario requires a speciic support both at network level (dynamic code deployment) and at node level (dynamic application management and concurrent execu- tion). Dynamic code deployment in WSNs has been an active research topic for many years, leading to several suitable solutions that are currently available in the market [1]. Node-level concurrency, on the contrary, has received much less attention so far and no ultimate solutions have been proposed. Existing approaches can be classiied into two Hindawi Publishing Corporation International Journal of Distributed Sensor Networks Volume 2014, Article ID 814510, 9 pages http://dx.doi.org/10.1155/2014/814510