| Wireless Sensor Networks (WSNs) are rapidly emerging as a new class of distributed pervasive systems, with applications in a diverse range of domains such as traffic management, building environment management, target tracking, etc. Most, if not all, WSN application design is currently performed at the node-level, with developers manually customizing various protocols to realize their applications. This makes it difficult for the typical domain-expert application developer (e.g., a building system designer) to develop applications for them, and is a hindrance to their wide acceptance. To address this problem, the field of macroprogramming has emerged, which aims to provide high-level programming abstractions to assist in application development for WSNs. Although several macroprogramming approaches have been studied, the area of compilation of these macroprograms to node-level code is still largely unexplored.;This thesis addresses the issues involved in the compilation of sensor network macroprograms. The emphasis is on data-driven macroprogramming, where the application is represented as a set of tasks running on the system's nodes - producing, processing and acting on data items or streams to achieve the system's goals. In addition to a modular framework for the overall compilation process, formal models for the task-mapping problem which arises in this context are discussed. Results from optimal result-producing mixed-integer programming techniques and algorithmic heuristics for the above problem are presented. We also present the design and implementation of a graphical toolkit for sensor network macroprogramming. |