Nano-RK: An Energy-Aware Resource-Centric Real-Time Operating System for Sensor Networks

10

Click here to load reader

description

By Eswaran, Rowe and Rajkumar at Carnegie Mellon University, Pittsburgh, PA

Transcript of Nano-RK: An Energy-Aware Resource-Centric Real-Time Operating System for Sensor Networks

Page 1: Nano-RK: An Energy-Aware Resource-Centric Real-Time Operating System for Sensor Networks

Nano-RK: an Energy-aware Resource-centric RTOSfor Sensor Networks

Anand Eswaran1, Anthony Rowe1 and Raj Rajkumar1,2

Real-Time and Multimedia Systems Lab1Electrical and Computer Engineering Department, {aeswaran,agr,raj}@ece.cmu.edu

2School of Computer ScienceCarnegie Mellon University, Pittsburgh, PA, USA

AbstractMany sensor networking applications such as surveillance andenvironmental monitoring are time-sensitive in nature. To sup-port such applications, we design and implement Nano-RK,a reservation-based real-time operating system (RTOS) withmulti-hop networking support for use in wireless sensor net-works. We support fixed-priority preemptive multitasking forguaranteeing that task deadlines are met, along with supportfor CPU and network bandwidth reservations. Tasks can spec-ify their resource demands and the operating system providestimely, guaranteed and controlled access to CPU cycles andnetwork packets in resource-constrained embedded sensor envi-ronments. We also introduce the concept of virtual energy reser-vations that allows the OS to enforce energy budgets associatedwith a sensing task by controlling resource accesses. A light-weight wireless networking stack supports packet forwarding,routing and TDMA-based network scheduling. Nano-RK hasbeen implemented on the Atmel ATMEGA128 processor withthe Chipcon CC2420 802.15.4 transceiver chip. Our resultsshow that a light-weight embedded resource kernel with richfunctionality and timing support is practical and constitutesa simple and alternative paradigm for supporting distributedsensing tasks.

1 IntroductionThe rapid proliferation of sensor networks has placed increas-ing demands upon the system infrastructure for supporting scal-able distributed sensor applications. As applications for sensorsin areas as diverse as security surveillance, traffic monitoring,smart spaces and smart buildings continues to grow, infrastruc-tural support for sensor network applications in the form ofsystem software is becoming increasingly important. The pushprovided by the scaling of technology and the need to supportincreasingly complicated and diverse applications has resultedin the need for traditional multitasking operating system (OS)abstractions and programming paradigms. The case for small-footprint real-time OS support in sensor networks is strength-ened by the fact that many sensor networking applications aretime-sensitive in nature i.e. the data must be delivered from thesource to the destination within a timing constraint. For exam-ple, in a surveillance application, data relayed by a task whichis responsible for detecting intruders and subsequently alertingthe gateway nodes of the system should be able to reach thegateway on a timely basis.

In this paper, we present Nano-RK, a small-footprint em-bedded real-time operating system with networking support.Nano-RK supports the classical operating system multitasking

abstractions allowing sensor application developers to work ina familiar paradigm resulting in short learning curves, quickerapplication development times and improved productivity. Weshow that an efficient implementation of such a paradigmis practical. We associate tasks with priorities and supportpriority-based preemption i.e, a task can always be preemptedby a higher-priority task that becomes eligible to run. Fortiming sensitive applications, we use priority-based preemptivescheduling to implement the rate-monotonic paradigm [18] ofreal-time scheduling so that a periodic sensor task set with tim-ing deadlines can be scheduled such that their timing guaranteesare honored. Since modern sensor networks use ad-hoc multi-hop wireless networking for packet relaying, we provide port-based socket abstractions that can be used by sensing tasks forsending and receiving data.

Since sensor nodes are resource-constrained and energy-constrained, we provide functionality whereby the operatingsystem can enforce limits on the resource usage of individualapplications and on the energy budget used by individual ap-plications and the system as a whole. In particular, we imple-ment CPU reservations and Network Bandwidth reservationswherein dedicated access of individual application to systemresources is guaranteed by the OS. The OS also implementssensor reservations to enforce usage on the number of accessesto individual sensors. Since the energy used by each task is thetotal sum of energy consumed by the CPU/microcontroller, theradio interface and the individual sensors, a particular settingfor each of these leads to an energy reservation. Since we usea static design-time approach for admission control, we pro-vide tools for estimating the energy budget of each applicationand (hence) the system lifetime. The CPU, network and sensorreservation values of tasks can be iteratively modified by thesystem designer until the battery lifetime requirements of thenode are satisfied.

1.1 Related WorkInfrastructural software support for sensor networks was in-troduced by Hill et al. in [13]. They proposed TinyOS, alow-footprint component-based operating system that supportsmodularity and concurrency using an event-driven approach.TinyOS 1.0 supports an event-driven model wherein interruptscan register events, which can then be acted upon by other non-blocking functions. We believe that there are several drawbacksto this approach. The TinyOS design paradigm is a significantdeparture from the traditional programming paradigm involvingthreads, making it less intuitive for application developers. Incontrast, we support a traditional multitasking paradigm retain-ing task abstractions and multitasking. Unlike TinyOS, wheretasks cannot be interrupted, we support priority-based preemp-

Page 2: Nano-RK: An Energy-Aware Resource-Centric Real-Time Operating System for Sensor Networks

tion. Nano-RK provides timeliness guarantees for tasks withreal-time requirements. We provide task management, task syn-chronization and high-level networking primitives for the de-velopers use. While our footprint size and RAM requirementsare larger than that of TinyOS, our requirements are consistentwith current embedded microcontrollers. A sensor network mi-crocontroller may typically have 32-64KB of ROM and 4-8 KBof RAM. Therefore, Nano-RK is optimized primarily for RAMand secondarily for ROM. SOS [11] is architecturally similar toTinyOS with the additional capability for loading dynamic run-time modules. In contrast to SOS, we propose a static, multi-tasking paradigm with timeliness and resource reservation sup-port.

The Mantis OS [12] is the most closely related work to oursin the existing literature. In comparison to Mantis, we pro-vide explicit support for periodic task scheduling that naturallycaptures the duty cycles of multiple sensor tasks. We supportreal-time tasksets that have deadlines associated with their datadelivery. We use the mechanisms of CPU and network reser-vations to enforce limits on the resource usage of individualtasks. With respect to networking we provide a rich API set forsocket-like abstractions, and a generic system support for net-work scheduling and routing. Nano-RK supports power man-agement techniques and provides several power-aware APIs forsystem use.1

While low-footprint operating systems such as µC/OS,OSEK and Emeralds [16] support real-time scheduling, they donot have support for wireless networking. Our networking stackis significantly smaller in terms of footprint as compared to ex-isting implementation of wireless protocols like Zigbee (around25 KB ROM and 1.5 KB RAM) and Bluetooth (around 50KBROM). We also provide high-level socket-type abstractions, andhooks for users to develop custom MAC protocols.

Our system infrastructure can be used to complement dis-tributed sensor applications such as an energy-efficient surveil-lance system ([1, 2]). Our contributions are compatible withthe literature on real-time networking / resource allocation pro-tocols [6, 10], energy-efficient routing/ scheduling schemes[4, 14] , data aggregation schemes [17], energy efficient topol-ogy control [9] and localization schemes [5, 8]. Nano-RK canbe used as a software platform for building higher-layer middle-ware abstractions like [3]. Our energy reservation mechanismcan also be used to prevent the type of energy DoS attacks de-scribed in [7].

Finally, our work complements [21] in extending the Re-source Kernel (RK) paradigm to energy-limited resource-constrained environments like sensor networks (and hence thename “Nano-RK”).

1.2 Organization of The PaperThe rest of this paper is organized as follows. Section 2 de-scribes the requirements and design goals of a real-time operat-ing system for sensor networks. Section 3 describes how a typ-ical sensor application can leverage the programming paradigmto create a distributed sensing application. In Section 4, we de-scribe the Nano-RK architecture and application programminginterface in detail. Section 5 describes our implementation ofNano-RK on the ATMega128 processor. Section 6 presents anearly evaluation of Nano-RK features. Finally, Section 7 sum-marizes our contributions and discusses potential avenues forfuture work.

1Power-aware APIs can also be used by applications, albeit with prudence.

Device Period Execution TimeRadio Sporadic 10 msMicrophone 200 Hz 10 usLight Sensor 166 Hz 10 msSmart Camera 1 Hz 300 msGPS 5 Hz 10 ms

Figure 1: An example sensor taskset.

2 Design Goals for a Sensor RTOSWe present the following design goals for an RTOS targetingwireless sensor networks.

• Multitasking: The OS should provide a simple and intu-itive programming paradigm for easy use by applicationdevelopers. It is desirable to retain the traditional multi-tasking paradigm familiar to both desktop and embeddedsystem programmers. Application developers should beable to concentrate on application logic rather than low-level system issues such as scheduling and networking.

• Networking Stack Support: The OS should support mul-tihop networking, routing and simple user-level network-ing abstractions similar to sockets. In particular, low-levelnetworking details such as reliable packet transmission,multicasting, queue management etc. should be handledby the OS.

• Support for Priority-based Preemption: Node batterylifetime continues to be a major challenge in sensor net-works. Hence, given that energy consumed by process-ing per bit is significantly less than the per-bit energy con-sumed by the radio interface, there is a trend toward in-creased local processing (such as embedded vision andsound processing). This typically results in increased taskexecution times. In such situations where task run-timesare large, there is a need for priority-based preemption togive precedence to higher priority events.

True preemptive multitasking becomes necessary in a sys-tem where multiple inputs to the system must be servicedat different rates within a required period. For instance,imagine a sensing platform consisting of a microphone,light sensor, radio interface, a GPS for position informa-tion or time synchronization and a smart camera system.Figure 1 shows typical periods and execution times forthese devices. Manually scheduling such a task set canbecome daunting using timer interrupts.

A non-preemptive scheme might handle the radio withan external interrupt, the light and microphone with twopriority-based timers, and leave the GPS and camera pro-cessing for the main program loop. Even in this situation,the developer may encounter difficulties because the cam-era servicing time is longer than the period of the GPS.Given that many low-end microcontrollers have limitedtimer interrupts, it can become difficult to schedule sucha task set. Developers may need to resort to manual timesplicing of their functions, thus making future modifica-tions difficult. With a preemptive priority-based system,each of these sensing functions would be supported by aprioritized periodic task.

Page 3: Nano-RK: An Energy-Aware Resource-Centric Real-Time Operating System for Sensor Networks

• Timeliness and Schedulability: Most sensor applicationssuch as surveillance tend to be time-sensitive in naturewhere packets must be relayed and forwarded on a timelybasis. While routing and network link scheduling are im-portant components in ensuring that packets meet theirend-to-end delay bounds, timing support on each node inthe network is also essential. In order to satisfy end-to-enddeadlines, local tasks on each node have deadlines asso-ciated with the completion of their local data relaying andprocessing. Managing the deadlines of these tasks requiressupport of a real-time operating system.

• Battery Lifetime Requirements: Guaranteeing sensornode battery lifetimes of 3 to 5 years is a very desirableobjective in many sensor networks. If limits on the usageof energy can be enforced, lifetime guarantee requirementsof the system as a whole can likely be provided (under rea-sonable assumptions about operating conditions such asnetwork connectivity). The OS can also ensure that thesystem energy is apportioned in a manner commensuratewith task importance such that critical tasks are guaranteedtheir energy budget.

• Enforcement of Resource Usage Limits: Since sensornodes are resource-constrained, precious CPU cycles, net-work buffers and bandwidth should be apportioned to ap-plication needs. OS support for guaranteed, timely andlimited access to system resources is conducive to sup-porting application deadlines and balanced apportioningof system slack (residual unused resources). This mech-anism can also be used to place some limits on the impactof faulty or malicious tasks on system operation.

• Unified Sensor Interface Abstraction: Providing a uni-fied and simple abstraction for accessing sensor read-ings and actuating responses would greatly benefit theend-user. In particular, low-level details associated withsensor/actuator configurations should be abstracted awayfrom the user. Sensors should be supported using devicedrivers that can return real-world units as well as raw ADCvalues.

• Small Footprint: The current trend of low-end embeddedprocessors is towards larger ROM sizes (64 KB to 128 KB)and smaller RAM sizes (2 KB to 8 KB). The OS architec-ture should be compliant with this trend by optimizing forRAM with a higher priority than ROM and optimizing forruntime efficiency. This memory constraint also impliesthat when the choice exists, one prefers a static configu-ration to a dynamic decision that requires additional datastorage and run-time manipulations.

3 Nano-RK Programming ModelIn this section, we show an example application that uses mul-tiple tasks running in Nano-RK to monitor sensors and relayinformation to a remote node. Each task operates at a differ-ent frequency and priority. The example network consists of asender node and a receiver node. The sender node hosts threetasks responsible for sensing sound, light and temperature. Thereceiver node collects packets from the sensing node and sets anLED signifying which sensor was triggered. The microphone issampled at 1 KHz and is filtered such that a packet is sent onlyif an increase in volume above a particular threshold is detected.If people enter a room and begin working, an initial packet issent. The system adjusts to the new ambient sound level, thus

suppressing future packets. The light sensor is monitored onceper second and a packet is transmitted only if the value changesbeyond a certain threshold averaged over the past 10 readings.This allows the sensor to detect sudden changes like when anoverhead light is turned on, but the task ignores slowly shiftingchanges in intensity levels like the sun moving during the day.The temperature sensor is read every three seconds and a packetis transmitted whenever the temperature changes by more than2 degrees from the previously transmitted packet. If the temper-ature exceeds a certain threshold indicating fire or some othersafety concern, a high priority packet is sent each time the sen-sor is read. The tasks are written using the C programminglanguage. Shown below is a sample task that communicates ona port. The prefix nrk_ is used on Nano-RK-specific datatypesand system calls (only for the sake of illustration).

void Sound_Task(){int i, status, sound,prev_sound;// Transmit Buffer Stored in App.char tx_buff[2];nrk_port_des my_port;

// setup socket on port 0 to broadcastport_des = nrk_port(tx_buff, 2, 0);// set to broadcast to all nodesnrk_connect(port_des, 0xFFFF);while (1) {

sound = read_sensor(MIC);printf("T1 Sound = %d\r",sound);tx_buff[0] = sound;if (sound_change(sound,prev_sound)) {

// Send Data using the socketnrk_port_send(my_port);wait_until_sent();printf("T1 Sent Packet\r");

}prev_sound = sound;nrk_suspend_task();

}}

The next code segment shows how a task is created, and how itsperiod and reservation are configured. Since we prefer a staticdesign-time approach, task parameters like period and reser-vation capacities are populated during initialization and imagecreation rather than at run-time using system APIs. However,API support is available for programmers who need flexible re-configurability of taskset properties. (These dynamic configu-ration calls can be unlinked from the final executable image ifdesired.)

nrk_task_type Task1;

Task1.task = Sound_Task;Task1.Ptos = (void *) &Stack1[STACKSIZE - 1];Task1.TaskID = 1;Task1.priority = 3;Task1.Period = 10;Task1.set_cpu_reserve = 5;Task1.set_network_reserve = 3;Task1.set_sensor_reserve = 3;nrk_activate_task (Task1);

The next code sample shows a receiver task. For the sake ofdemonstration purposes, each type of sensor packet is collectedby a different task listening on a different port. The task runsat a priority based on its CPU reservation parameters, which inturn will likely depend on the sensor frequency.

void Get_Sound_Task(){

Page 4: Nano-RK: An Energy-Aware Resource-Centric Real-Time Operating System for Sensor Networks

Figure 2: Nano-RK Architecture Diagram

int i, status;char rx_buff[2];nrk_port_des my_port;

// setup receive socket on port 0my_port = nrk_port(rx_buff, 2, 0, 0);// Listen on this socket for a packetnrk_listen(my_port);

while (1) {CLR_LED(); // clear indicator// Non-block call to wait// for data on this socketnrk_port_read();nrk_wait_until_read();SET_LED(); // light up reception indicator

}}

The Appendix lists the complete set of Nano-RK APIs.

4 The Nano-RK ArchitectureThe particular requirements of systems support in sensor net-working that were discussed earlier impose unique challengeswith respect to designing an RTOS. In this section, we describethe architecture of Nano-RK, its constructs and capabilities.The overall system architecture of Nano-RK is shown in Fig-ure 2.

4.1 Static ApproachGiven the memory constraints of embedded sensor operatingsystems, Nano-RK uses a static design-time framework. Thisapproach is consistent with sensor networking assumptions be-cause as compared to traditional operating systems (where pro-cesses can be dynamically spawned), the OS and the applica-tions are co-located in a single address space. In particular,admission control and real-time schedulability analysis testsare carried out offline as compared to taking a dynamic onlineapproach. We would like to stress that a static approach doesnot mean that task properties and configuration parameters can-not be reconfigured during run-time. Rather, a static approachenforces the checks to ensure that the dynamic reconfigurationdoes not adversely affect application and system guarantees in apre-deployment offline setting as compared to running dynamicadmission control algorithms. Data- (or control-) dependentmodifications to the task code such as changing task periods, re-source usage limits, resource priorities and configuration of var-ious parameters such as the network buffer sizes and stack sizesof each task can be changed to accommodate mode changes.

With current energy and memory constraints, the run-time con-figurations will need to be verified offline at design-time2. Thisresults in a light-weight operating system with a small footprintwhile retaining the rich set of functionality found in conven-tional RTOSs.

4.2 The Reservation ParadigmThe reservation paradigm, as implemented in a Resource Ker-nel [21], is a simple and practical paradigm for guaranteeingtimeliness and enforcing temporal isolation in real-time oper-ating systems. In resource kernels, applications specify time-liness and resource requirements, and the OS enforces guaran-teed access to system resources and schedules tasks so that theapplication timeliness requirements are satisfied. While the re-source kernel abstraction has so far been used in dynamic run-time settings, the resource reservation paradigm is desirable forstatic settings as well. A sensor application task can specify itsrequirement of CPU cycles, network bandwidth and networkbuffers over fixed periods which will be enforced by the Nano-RK kernel. Only tasks that have not depleted their reservationquota rates are eligible for scheduling. In deference to the strin-gent constraints of sensor nodes, exactly a single task is associ-ated with a reservation. In contrast, the classical resource ker-nel concept allows for zero, one or more tasks to be bound to areservation.

In summary, Nano-RK supports CPU reservations,sender/receiver network bandwidth reservations and sen-sor/actuator reservations. All of these reservations can becombined to enforce a virtual node-wide (and perhaps evensystem-wide) energy reservation.

4.3 Power Awareness SupportSince maximizing battery lifetime is often a primary objectivein sensor networks, there is a need for aggressive power savingsby operating at low duty cycles. Nano-RK enforces this in theform of virtual energy reservations. Note that the energy con-sumed by a task is the total sum of the CPU/microcontroller en-ergy, radio interface energy and the energy associated with turn-ing on sensors and actuators. The CPU and radio energy con-sumed by the task can be adjusted fairly accurately by chang-ing the CPU and network reservation sizes. In order to boundthe energy consumed by sensors, Nano-RK provides sensorreservations. Our unified sensor interface provides function-ality wherein sensors are turned off (gated) by default and anyaccess to a sensor is an atomic operation that consists of the sen-sor being turned on, its value being read and then being turnedoff again. This makes it possible for the operating system toset an upper limit on the number of accesses made to a sensorover a particular period. Thus it is is possible to map a resourcetuple of (CPU,Network, Sensor) reservations to a particularpower level. Given periodic tasks, one can calculate the meanpower used by all tasks over a hyper-period, giving a reason-ably accurate estimate of the node lifetime. By modifying thevalues of the (CPU,Network, Sensor) reservation-tuple, themean energy consumed by each task can be varied. This canbe used for either controlling the node lifetime or for varyingthe proportion of system energy allotted to each task (for exam-ple, certain mission-critical tasks can be allocated a high energybudget). We again note that energy reservations is implementedby controlling the (CPU,Network, Sensor) reservation-tupleat a pre-deployment stage. This is consistent with the predomi-nantly static approach that Nano-RK adopts.

2Future revisions of Nano-RK may relax this constraint.

Page 5: Nano-RK: An Energy-Aware Resource-Centric Real-Time Operating System for Sensor Networks

Figure 3: FireFly Sensor node w/ ultrasonic sensor.

4.4 Socket Abstractions and RoutingSince sensor nodes operate in a multihop networking environ-ment, it may be necessary to route data periodically from sen-sor nodes to one or multiple gateways, or among nodes in aneighborhood for local coordination. Thus, nodes would benefitgreatly from a sockets-like abstraction that masks the low-leveldetails of MAC scheduling and routing from the application.In typical distributed sensor tasks, multiple nodes co-ordinateto achieve a common objective (e.g. sensing the presence ofan intruder). Nano-RK’s socket-like abstractions allow tasksto communicate with each other, with APIs for enabling a taskto bind to a unique port. For memory efficiency, applicationshandle their own data buffers. The operating system is respon-sible for populating application buffers upon the reception ofpackets. The OS is also responsible for handling (reliable orunreliable) one-hop transmission of packet on behalf of the ap-plication. With corresponding OS control flags, it is possible tocollapse multiple packets that have a common “next hop to des-tination” into a single packet, thus resulting in energy-efficientdata forwarding.

Routing table data structures and destination look-up func-tions are managed by Nano-RK. We provide the basic infras-tructural support over which ad-hoc routing protocols such asAODV [20] and DSR [19] can be implemented in the OS.

5 An Implementation of Nano-RKIn this section, we describe in detail our implementation of astatic reservation-based preemptive operating system and thenetworking stack for the Atmel ATMega128 using the Chip-con CC2420 radio interface. Figure 4 shows a breakdown ofNano-RK’s current resource requirements.

5.1 Hardware and Sensor SupportNano-RK currently operates on an Atmel ATMEGA128-basedsensor node shown in Figure 3 called FireFly built at CMU.The ATMEGA128L processor is an 8-bit microcontroller con-sisting of 128 KB of code space and 4 KB of data memory. Ituses the Chipcon CC2420 802.15.4 wireless transceiver chip forcommunication. The platform has the following sensors: light,temperature, sound, passive infrared motion detection, and dualaxis acceleration. In addition to sensors, the board has an ultra-sonic transceiver add-on and 1 MB of external flash memory.All sensor peripherals can be gated by the main processor toconserve power. The processor has two internal 8-bit and four16-bit timers, an 8-channel 10-bit ADC, a watchdog timer andsix different sleep modes. The instruction set includes 135 in-structions with multiplication instructions taking two clock cy-cles and the rest executing in a single cycle.

Power EnergyCPU (0.05mW ∗ tidle) +

(24.0mW ∗ tactive)Idle 0.05mW 0.05mW ∗ tidleActive 24.0mW 24.0mW ∗ tactiveNetwork (.06mW ∗ tidle) + (1.8µJ ∗

Nrx_bytes) + (1.6µJ ∗Ntx_bytes)

RX 59.1mW 1.8µJ per byteTX 52.1mW 1.6µJ per byteIdle .06mW .06mW ∗ tidleSensorLight, Temp .09mW 11.25nJ per readingMicrophone 2.34mW 2.87µJ per readingPIR 5.09mW 1µJ per readingAccel 1.8mW 11.25nJ per readingUltrasonic TX 60mW 15µJ per pingUltrasonic RX 30.8mW 30.8mW ∗ tactive

Table 1: Energy statistics for current hardware setup.

Most of the sensors use the Atmel’s onboard analog to dig-ital converter (ADC), with the exception of the accelerometerwhich requires software PWM (pulse width modulation) de-coding. Nano-RK provides a set of sensor system calls thatread raw sensor data and convert the data into meaningful units.It also ensures that the sensor reservations are updated whenthese calls are made. These functions are atomic, preventingdeadlock due to hardware communication interruptions.

5.2 Task Management and SchedulingNano-RK task control block (TCB) structures are populatedduring initialization and system image creation3. They storethe register context of all task (registers and stack), the task’spriority, period of recurrence, (CPU, network, Sensor) reser-vation sizes, port identifiers etc. Two linked lists of TCB point-ers are used to order the set of active and suspended tasks re-spectively, based on period of recurrence. Tasks can block oncertain events (such as being awakened at a certain point of timeor the arrival of a network packet) and can be unsuspended andenqueued in the OS active list when the pending events occur.We suspend tasks that have pending events rather than using apolling-based implementation of Nano-RK system calls. This isdone for energy-efficiency reasons because if there are no taskseligible to run, the system can be powered down to sleep.

Our system uses priority-based preemptive scheduling andwhile we provide explicit support for periodic tasks, we alsosupport aperiodic and sporadic tasks in our framework. Thehighest priority task that is eligible to run in the system is al-ways scheduled by the operating system. A periodic task cansuspend itself after the completion of its current instance usingthe wait_until_next_period() system call.

We implement priority ceiling protocol emulation (HighestLocker Priority protocol) to bound the blocking time encoun-tered by a higher priority process due to the phenomenon of pri-ority inversion (wherein a shared resource needed by the high-priority process is currently being used by a lower-priority pro-

3While we provide API support to modify fields in the TCB during run-time,we encourage a static configuration for a small-footprint ROM image.

Page 6: Nano-RK: An Energy-Aware Resource-Centric Real-Time Operating System for Sensor Networks

Component ResourceContext Swap Time 45 µsMutex Structure Overhead 5 bytes per resourceStack Size Per Task 32→ 128 (typically 64) bytesOS Struct Overhead 50 bytes per taskNetwork Structure Overhead 164 bytes8 tasks, 8 mutexes, and4 16-byte network buffers < 2KB RAM, 10KB ROM

Figure 4: Breakdown of a Nano-RK configuration.

cess). In particular, each mutex is associated with a priority ceil-ing. When a mutex is acquired (using lock_mutex()), thepriority of the task is elevated to the priority ceiling of the mu-tex. Once the mutex is released (using the unlock_mutex()system call), the priority of the task reverts to its original level.This results in bounded priority inversion which can be ac-counted for in the offline schedulability test. Thus, real-timesynchronization is supported in Nano-RK.

Rather than provide explicit message box support, we pro-vide system support for conventional semaphores that can beused by tasks to manipulate application buffers in a con-trolled manner for facilitating inter-process communication (us-ing message boxes). This obviates the necessity for OS bufferspace for storing message data and allows efficient zero copying[15] mechanisms to facilitate information sharing among tasks.Semaphores can also be used as a generalization of mutexes forguarding access to multiple resources.

5.3 TimingOur implementation is based on the POSIX time structuretimeval. We use a structure composed of two 32-bit num-bers to represent (seconds, nanoseconds) fields in ourtime structures. For periodic tasks, we operate the timer in aone-shot mode wherein the next timing interrupt is triggeredwhen either a task is scheduled to be awakened because of anevent or because it becomes eligible for scheduling. In eithercase, the global TOD (time of day) counter field in the OS is up-dated. The TOD counter field is incremented periodically, andoverflows will not occur for practically foreseeable intervals oftime. Our system thus allows support for fine-granularity tim-ing requirements of real-time applications while maintaining a(practically) non-overflowing notion of absolute time.

5.4 Reservation SupportCPU reservations are created statically by populating the cor-responding task’s TCB structure with reservation information4.In order to support CPU reservations, we associate each taskwith a ticks_consumed field, that accounts for the CPU cy-cles used by that application. When the ticks_consumedparameter exceeds the reservation size quota (reservation) spec-ified by the system call, based on the policy of the reservation(hard or soft) one of the two following operations is carriedout: if the reservation policy is hard, the application is imme-diately suspended and the reservation is replenished during thenext period; if the reservation policy is soft, the application canconsume the slack cycles unused by other tasks and when the

4We also support using cpu_resv_create() andcpu_resv_modify() APIs during run-time. However, we stress thatthese calls should be used with discretion to prevent malicious/faulty applica-tions from dominating the use of system resources.

system slack is depleted, it is suspended. For soft reservations,the CPU reservation quota is replenished during the next pe-riod of that task independent of whether slack resources wereconsumed or not. Since we take an offline approach, Nano-RKhas full knowledge of system slack cycles. We allow an ap-plication to query the status and usage of its reservation usingthe cpu_resv_query() so that it can potentially adapt itsbehavior accordingly. Highly energy-sensitive deployments ofNano-RK environments will likely discourage or even disallowthe use of soft reservations, due to the excess energy that can beconsumed by prolonged execution or communications.

Network reservations are implemented statically by config-uring the task TCB structures with parameters for setting aquota on the network bandwidth that is usable by that partic-ular task. We provide two types of network reservations: net-work sender reservations that set a limit on bytes or packetsthat can be transmitted in a given period and network receiverreservations that enforce limits on the amount of received dataor active radio receiver time in a given period. Each time apacket is received, task TCB parameters bytes_consumedand packet_used are incremented. When the network band-width quota equals the network reservation size, based on thenetwork reservation policy of hard or soft, the application is ei-ther suspended or is eligible to access slack bandwidth in thesystem. The packet-count reservation sets a quota for the ra-dio energy consumed while the number of bytes over a periodenforces the limits on bandwidth consumption.

Sensor reservations are implemented in a similar manner bystatically populating task TCB parameters to specify the num-ber of times a sensor can be read in a given period. Eachsensor_read() call increments a counter. If this counterexceeds the reservation quota, the process is suspended and thequota is replenished during the next period of the task.

As discussed earlier, virtual energy reservations canbe implemented by judiciously choosing values of(CPU,Network, Sensor) reservation values.

5.5 Network Protocol StackNano-RK contains a lightweight network protocol stack that al-lows for port-based communication. Since the network stackis tightly integrated with the OS and execution/communicationinformation is available, optimizations using global applica-tion knowledge such as automatic packet aggregation, networkreservations, and buffer management are possible. An incom-ing data packet triggers an interrupt that handles the arrival ofthe packet. Packet transmissions are handled by a periodic net-work task responsible for servicing all outgoing packets of alltasks.

In traditional Unix-based systems, the OS is responsible forallocating and managing buffers for network communication.Statically allocating uniform buffers can be wasteful in sen-sor applications that transmit and receive only a few bytes perpacket. In Nano-RK, the networking buffers are sized and allo-cated by the applications, but are managed by the network stackusing a zerocopy buffer mechanism [15]. Upon successful re-ception of a packet by the OS interrupt routine, a data readystatus flag is set that allows the application to directly manipu-late the memory. The memory will not be touched again by theOS until the application explicitly resets the data ready statusflag (using port_receive_release() or by calling an-other port_read() command). This allows the applicationdeveloper to process the data in place to conserve memory andCPU cycles.

Packets transferred over the network contain a port and a des-tination address in their header. Upon reception of a packet des-

Page 7: Nano-RK: An Energy-Aware Resource-Centric Real-Time Operating System for Sensor Networks

Figure 5: Nano-RK network stack showing placement ofbuffers in the application.

tined for the current node, the port is extracted from the headerand used to identify which buffer the packet’s data should beplaced into. If the destination address is configured as a broad-cast packet (0xFFFF), then all applications in the network thatare listening on a particular port will receive the data. Unlike thetraditional socket model, multiple applications on the same sen-sor node can listen on a single port. In this mode of operation,all listening applications must read the data before the OS willupdate the port with new packets. Though this would necessi-tate handling conflicts at the user level, it allows for multipleapplications to share buffers, thus saving memory. Tasks thatdo not want to handle such conflicts can choose to use uniqueport numbers.

Information describing each socket is stored in a port_desdata structure. This structure contains a pointer to the pay-load buffer, the size of the buffer, the port, destination address,message priority and hardware-specific parameters. The struc-ture is instantiated through the use of the port() functioncall. The port_des data structure must then be passed toall transmit and receive functions. The hardware-specific pa-rameters in this structure allow full configuration of the Chip-con CC2420 features such as encryption, radio transmit power,CRC error checking, clear channel assessment, and frequencyselection. Internally, the OS contains an array of pointers toport data structures. This array is indexed by the port num-ber. The server functionality of the network stack consistsof three main commands: listen(), sock_read() andselect(). The listen() function takes a port data de-scriptor as a parameter and is used to notify the OS that theapplication is expecting packets on a particular port. When apacket is received by the radio transceiver, an external inter-rupt routine is triggered which reads the packet from the radio’sFIFO. Header information is collected before data, allowing theinterrupt routine to take appropriate action without bufferingthe entire packet. If the destination address matches the currentnode’s address, then the port is used to direct the memory intothe application-defined buffer. If the port is unknown or foundto be busy, then the packet is either dropped or is overwrittenin the buffer (depending on a user-defined replacement policy).After the packet has been copied into the correct buffer, a sta-tus flag associated with that port is set, handing control of thebuffer to the application. At this point, the scheduler is calledto see if a task is waiting on an incoming packet. Once it re-

sumes execution, the task can gain access to the buffer usingthe port_read() function. The port_read() functionis non-blocking returning 1 only if a packet was correctly re-ceived. The OS will not update that buffer until the applicationhas relinquished its control with either another port_read()call or an explicit port_read_release() call. Usingthe wait_until_read() function call, the application canblock until a packet has been received. The select() func-tion can be called with an 8-bit port index mask and a time-out. This is similar to the original BSD sockets implementationwhich supported 32 open file descriptors per process, and usedone bit corresponding to each file descriptor in the mask. Theselect() function will hand over control of the task and notreturn until a matched packet is received or the timeout expires.If a selected packet is received, then select() will return itsport descriptor.

The interface to the client functionality of the network stackconsists of a connect() command and a port_write()function. The connect() command registers the outgoingport descriptor with the network stack. The port_write()command takes as an argument a port descriptor and updatesa data ready field. Each time the network task is called, itwill check all registered ports to see if there is a pending mes-sage for transmission. If more than one message resides inthe transmit queue, the priority fields can determine the orderin which they are to be sent. If the "next hop" of the mes-sages are identical and have a size smaller than the maximumpayload size, then the messages are aggregated and sent as asingle packet. Since the application and OS share the samebuffer, port_write_status() can be used to check if thepacket was sent by the network task before updating the existingbuffer with new data. The task can also turn over control untilthe packet is sent using the wait_until_sent() schedulercommand.

5.5.1 Routing and MAC SupportRouting and MAC protocols in sensor network environmentscan be dramatically different (compared to traditional networks)and even be application-specific. Nano-RK tries to isolate thisfunctionality allowing developers to implement their own pro-tocols. We provide a basic template for a CSMA-CA MAC pro-tocol with static routing tables. Though it is beyond the scopeof this paper, we have also developed a TDMA-based proto-col that utilizes global time synchronization to schedule packettransmissions. In the following section, we will discuss the in-frastructure currently in place allowing for custom MAC androuting protocols.

When a packet is received by the OS, a routing function iscalled by the receive packet interrupt. This routing function canthen access a routing table to determine if the current node isalong the path to the destination. The routing function can alsoreceive control packets such as route request packets used inad-hoc routing protocols like AODV and DSR. These controlpackets have the ability to add, remove or update entries in therouting table. If the destination of the packet is found in therouting table, then the packet is added to a forwarding bufferinside the OS. Like any normal application transmit buffer, thisforwarding buffer will be checked the next time the networkingtask is called.

The MAC layer control resides for the most part in the trans-mit portion of the network task. The only MAC layer controlrequired in the receiver interrupt is the ability to automaticallyand immediately acknowledge a received packet to ensure re-liable transmission. The MAC layer functionality such as col-

Page 8: Nano-RK: An Energy-Aware Resource-Centric Real-Time Operating System for Sensor Networks

Figure 6: Low Power Listen transmit and receive waveforms.

lision sensing back-off times or TDMA-based access schemesare also incorporated into the networking task. Since this taskis periodically called by the OS and is responsible for all datatransmissions, it is the ideal place to implement custom MACprotocols. Along these same lines, Nano-RK includes a driverfor low-level radio controls.

6 Experimental EvaluationIn this section, we provide simple examples that use the Nano-RK infrastructure. The first example is a power-efficient multi-hop networking MAC. The second example demonstrates howthe energy reservation functionality provided by the OS can beused to guarantee pre-specified network (battery) lifetimes.

6.1 Low-Power Listening MACIn this section, we show how the abstractions of periodic tasksnaturally capture the duty cycle of distributed sensing applica-tions. Using a method similar to Low-Power Listening (LPL)described in [22], we tested sending data over multiple hops.Figure 6 shows the basic operation of LPL. The receiver wakesup once every tper for a short duration (100µs) to assess thechannel. If a message preamble is detected, the receiver con-tinues to stay awake in order to receive the packet, otherwise itgoes back to sleep. This implies that the sender needs to trans-mit a preamble for a period long enough for the receiver to hearit i.e, the transmitter synchronization preamble pulse width istper . There is an inherent trade-off between receiver power andtransmitter power for operating at a particular application dutycycle and at a particular tper . We would like the OS networktask period (which is equal to tper) to be set such that the totalenergy expended per packet is minimized. In the graph shownin Figure 8, we consider the effects of total energy consumedas a function of tper for a 4-node chain where the applicationduty cycle requirements are 1 packet every 10 seconds. Thispacket contains the aggregated readings of temperature, lightand sound sensors. For this configuration with our hardwaresetup, we experimentally found the optimal tper to be around100ms, as shown in the graph. We also plot the multihop end-to-end latency associated with the delivery of packets in the 4-hop chain network for the same period of the network task.

6.2 Effectiveness of Energy ReservationsIn this subsection, we show how energy reservations and net-work bandwidth reservations can be utilized to maximize thenetwork (battery) lifetime of sensor networks. Most sensor net-works are topologically organized to form a forwarding tree thatpushes sensor data to one or more gateway. The duty cycles of

Figure 7: Sensor testbed setup. Topology (a) used for MACexperiment, (b) used for energy reservation experiment

50 100 150 200 250 300 350 400 450 5000

20

40

60

80

100

120

140

160

180

200

Period (ms)

Ene

rgy

(mW

) and

Lat

ency

(*10

ms)

EnergyLatency

Figure 8: Graph of energy and multi-hop packet latency vsduty-cycle length. Packet latency was measured over four hopswith a packet being sent once every 10 seconds.

the individual nodes are chosen judiciously in order to guar-antee the lifetime requirements of the sensor network. Whileimplementing large distributed sensing systems, it is possible,even likely, that application code on one or more sensor nodesis configured in an energy-unfriendly manner by transmittingan excessive number of packets or by not aggressively turningits power components off. OS-enforced energy reservations arecritical in ensuring that the network remains connected over itsoperational lifetime.

Our experimental setup consisted of a sensor network thatwas arranged as shown in Figure 7 with a target lifetime of 2years.

The duty cycles for achieving the lifetime requirements of 2years are shown in Table 2. Since forwarding functionality ishandled by the OS, if reservations were not used, the OS wouldsimply forward packets further up the tree. We considered an

Node Reserve[TX pkt/10 sec,RX pkt/10 sec]

TX Rate[pkt/10 sec]

TotalPacketsHandledwithoutReserve

TotalPacketsHandledwithReserve

a [1,2] 1 720 720

b n/a 300 216000 216000

c [1,2] 1 1362 1350

d [1,2] 1 195113 1358

e [1,2] 1 196643 3211

Table 2: Enforcement from Energy Reservations

Page 9: Nano-RK: An Energy-Aware Resource-Centric Real-Time Operating System for Sensor Networks

energy-efficient variant of naive packet forwarding where thenetwork tasks of nodes higher up in the tree hierarchy collapsedata belonging to their children in their forwarding buffers andtag their data forming a single packet. This aggregated packet isthen forwarded up the tree. This is possible because sensor datapayload sizes are typically small (2-4 bytes). In such a scenario,the duty cycles of all nodes5 in the tree are typically equal. Asensor module operating on node d was configured incorrectlyto send 300 packets every 10 seconds rather than 1 packet every10 seconds.

Two experiments were conducted, one without energy reser-vations and another with energy reservation in place. The totalnumber of packets handled6 by each board was monitored for 2hours for each experiment. The energy reservation for a node isenforced by setting a limit on the number of packets transmittedand on the time that the radio receiver is kept on.

After collecting the counter values for each node shown inTable 2, we used the sensor node’s power characteristics shownin Table 1 to calculate the mean power for each node and fromthe node with maximum mean power, the network lifetime wascalculated assuming a 2000 mAH battery. The network lifetimewas found to be 34 days and 2.9 years when reservations werenot used and used respectively. This demonstrates how reserva-tions can find natural practical applications in designing robustsensor networks and contribute to significant improvements.

7 Conclusions and Future WorkIn this paper, we described Nano-RK, a reservation-basedenergy-aware real-time operating system with wireless net-working support for resource-constrained sensor network en-vironments. We support a classically structured multitaskingOS with API support for task management, synchronization,IPC and high-level networking abstractions, with these func-tions specifically tailored to the constrained sensor network en-vironments. We enforce limits on CPU, bandwidth and sen-sor usage of individual tasks by using a reservation-based ap-proach to enforce bounds on timeliness, QoS and node life-time. We adopt a static design-time approach as compared toa dynamic run-time approach for creating an embedded sensortaskset. Our OS design uses several optimizations for memory-and energy-efficiency reasons while retaining a rich set of capa-bilities. Nano-RK will be made available for public use in thenear future.

While we have shown that traditional RTOS abstractions arepossible and natural for supporting sensor networking applica-tions, there are several additions, enhancements, and optimiza-tions that we are currently exploring. In particular, while thebasic operating system abstractions are in place, the networkingarchitecture of our sensor network is still work-in-progress. Wedo not currently support end-to-end deadline guarantees associ-ated with packet delivery and are exploring scheduling and rout-ing schemes based on Time Division Multiple Access (TDMA)scheduling using global time synchronization. We currentlysupport only static routing and are exploring the use of opti-mized dynamic energy-efficient custom routing schemes. Wealso plan to make further optimizations to the OS for support-ing energy-efficiency including support for low duty-cycle op-eration using TDMA techniques. We are currently designingOS-supported bootstrapping protocols for initializing and con-figuring the taskset parameters and for the distributed collection

5This is expressed as a per-task receive-time budget.6This was achieved by maintaining separate counters for number of packets

transmitted and number of packets received.

of connectivity information for large-scale sensor networks.Acknowledgements: This work was supported in part by

the Office of Naval Research, the National Science Foundation,Bosch Corporation and by Taiwan’s Institute for InformationIndustry.

References[1] Tian He, Sudha Krishnamurthy, John A. Stankovic, Tarek Abdelzaher, Liqian Luo,

Radu Stoleru, Ting Yan, Lin Gu, Jonathan Hui, Bruce Krogh. Efficient SurveillanceSystem Using Wireless Sensor Networks MobiSys’04, Boston, MA, June 2004.

[2] Juang P, Oki H, Wang Y, Martonosi M, Peh L-S, Rubenstein D Energy-efficientcomputing for wildlife tracking: design tradeoffs and early experiences with zebranetIn Proceedings of ACM ASPLOS Conf, 2002

[3] Tarek Abdelzaher et al EnviroTrack: Towards an Environmental Computing Paradigmfor Distributed Sensor Networks IEEE International Conference on Distributed Com-puting Systems, Tokyo, Japan, March 2004

[4] Hyung Seok Kim, Tarek Abdelzaher, Wook Hyun Kwon Minimum-Energy Asyn-chronous Dissemination to Mobile Sinks in Wireless Sensor Networks ACM SenSys,Los Angeles, CA, November, 2003.

[5] Tian He, Chengdu Huang, Brian Blum, John Stankovic, Tarek Abdelzaher Range-Free Localization Schemes for Large Scale Sensor Networks The 9th Annual Interna-tional Conference on Mobile Computing and Networking (Mobicom), San Diego, CA,September 2003

[6] John A. Stankovic, Tarek Abdelzaher, Chenyang Lu, Lui Sha, Jennifer Hou Real-Time Coomunication and Coordination in Embedded Sensor Networks Proceedingsof the IEEE, Vol. 91, No. 7, July 2003.

[7] A. D. Wood and J. Stankovic Denial of Service in Sensor Networks IEEE Computer,35(10):54-62, 2002.

[8] Wei-Peng Chen, Jennifer C. Hou, and Lui Sha Dynamic clustering for acoustic targettracking in wireless sensor networks IEEE Trans. on Mobile Computing, Special issuein self-reconfiguring sensor networks, Vol. 3, Number 3, July-September 2004.

[9] Ning Li, Jennifer C. Hou and Lui Sha Design and analysis of a MST-based distributedtopology control algorithm for wireless ad-hoc networks IEEE Trans. on WirelessCommunications, Vol. 4, No. 3, pp. 1195–1207, May 2005.

[10] Simone Giannecchini, Marco Caccamo, Chi-Sheng Shih Collaborative ResourceAllocation in Wireless Sensor Networks ECRTS 2004: 35-44

[11] Simon Han, Ramkumar Rengaswamy, Roy S Shea, Eddie Kohler, Mani B Srivas-tava SOS : A Dynamic Operating System for Sensor Nodes In Third InternationalConference on Mobile Systems, Applications and Services (Mobisys) June 2005

[12] H. Abrach, S. Bhatti, J. Carlson, H. Dai, J. Rose, A. Sheth, B. Shucker, J. Deng,R. Han MANTIS: System Support For MultimodAl NeTworks of In-situ Sensors 2ndACM International Workshop on Wireless Sensor Networks and Applications (WSNA)2003

[13] Jason Hill, Robert Szewczyk, Alec Woo, Seth Hollar, David Culler, Kristofer Pis-ter System architecture directions for network sensors ASPLOS 2000, Cambridge,November 2000.

[14] Wei Ye, John Heidemann, and Deborah Estrin. An Energy-Efficient MAC protocolfor Wireless Sensor Networks. In Proceedings of the IEEE Infocom, pp. 1567-1576June, 2002.

[15] Hsiao Keng, and J. Chu Zero-copy TCP in Solaris Proceedings of the USENIX,1996.

[16] Zuberi, K. M., Pillai, P., and Sin, K. G. EMERALDS: A small-memory real-timemicrokernel In Proceedings of the 17th ACM Symposium on Operating System Prin-ciples ACM Press, pp. 277–291. June 1999

[17] Chalermek Intanagonwiwat, Ramesh Govindan and Deborah Estrin Directed dif-fusion: A scalable and robust communication paradigm for sensor networks In Pro-ceedings of the Sixth Annual International Conference on Mobile Computing and Net-working (MobiCOM ’00), August 2000

[18] C. L. Liu and J. W. Layland Scheduling Algorithms for Multiprogramming in a HardReal-Time Environment Journal of the ACM, V20, N1, 1973, pp. 46-61.

[19] D. Johnson and D. Maltz. Dynamic Source Routing in Ad Hoc Wireless Networks.In T. Imielinsinki and H. Korth, Editors. Mobile Computing. Kluwer Academic Pub-lishers, 1996

[20] C. Perkins, E. Belding-Royer, and S. Das. Ad hoc On-Demand Distance Vector(AODV) Routing. In IETF RFC 3561, July 2003.

[21] R. Rajkumar, K. Juvva, A. Molano, and S. Oikawa. Resource kernels: A resource-centric approach to real-time and multimedia systems. In Proc. of the SPIE/ACMConference on Multimedia Computing and Networking. January 1998

[22] J. Polastre, J. Hill, D. Culler Versatile Low Power Media Access for WirelessNetworks In SenSys November 2004

Page 10: Nano-RK: An Energy-Aware Resource-Centric Real-Time Operating System for Sensor Networks

Appendix. The Nano-RK APIThe system calls provided by the OS can be classified based onfunctionality. In its default configuration, Nano-RK supports amaximum of 16 tasks, 16 ports, 8 mutexes and 8 semaphores.For richer (or poorer) environments, constants in header fileswill need to be consistently re-defined.

Task Management APIs

activate_task() Activates a periodic task; an aperi-odic task has a period of -1

wait_for_next_period() Suspend task until beginning ofnext period

wait_until() Suspends Task until absolute time Twait() Suspends task for at least tget_tid() Returns TID of current taskterminate_task() Permanently ends a periodic task∗get_priority() Returns priority of specified task∗set_priority() Changes priority of specified task

Network Communication APIs

port() Set parameters and returnport_des

connect() Register port_des with network tasklisten() Listen for message on port_desport_send() Non-blocking sendport_send_status() Check if message was sentport_receive() Non-blocking readport_receive_release() App finished with rx bufferwait_until_received() Block until packet receivedwait_until_sent() Block until packet sentselect() Block until one wakeup event, or a

timeout

Task Synchronization APIs

set_priority_ceiling() Sets mutex priority ceilingget_priority_ceiling() Gets mutex priority ceilingsem_init() Creates a semaphore and sets it to vsem_wait() P(sem) wait for s>0 then s=s-1sem_signal() V(sem) s=s+1lock_mutex() Puts data into a message boxunlock_mutex() Receives data from a message box

Sensor APIs

init_sensor() Initialize a sensorget_sensor_status() Returns the status of a sensorset_sensor_status() Sets a sensor parameterread_sensor() Returns a sensor valueconvert_sensor() Translate sensor value to real world

unitwait_until_sensor() Suspend task until a sensor com-

pletespower_wake() Power up a sensorpower_down() Power down a sensor

∗This functionality may be optionally removed or unlinked from Nano-RKdue to their run-time implications. Please use with caution.†Transmit power will be set in conjunction with the routing scheme.

Reservation APIscpu_rsv_query() Queries CPU reserve properties∗cpu_rsv_modify() Modify CPU reserve propertiesnetsndr_rsv_query() Queries network sender reserve

properties∗netsndr_rsv_modify() Modifies network sender reserve

propertiesnetrcvr_rsv_query() Queries network receiver reserve

properties∗netrcvr_rsv_modify() Modifies network receiver reserve

propertiessnsr_rsv_query() Queries sensor reserve properties∗snsr_rsv_modify() Modify sensor reserve properties

Power Management APIs

query_energy() Query residual battery energyset_energy_mode() Set energy savings mode (future)get_energy_mode() Get energy savings mode (future)†tx_power_set() Change radio transmitter powerpowerdown() Power the system down for t sec-

onds

Radio APIsradio_init() Initialize the radioradio_config() Configure the radioradio_rx_on() Turn on the radio receiverradio_rx_off() Turn off the radio receiverradio_tx_packet() Transmit a packetradio_read_byte() Read a byte of a packet

Scheduling APIs

set_period() Sets period of taskset_deadline() Sets deadline of periodic taskget_time() Returns global OS timeset_sched_policy() Changes the scheduling policy used

UART APIskprint() Safe print to serial portset_UART() Sets the UART parametersputc() Sends a single character over the

UARTgetc() Read a character from the UART

Routing APIs†add_route() Delete route from routing tabledel_route() Add a route into the routing table