## 3 Related Technologies
### Node Remote Reprogramming Mechanisms
#### 3.4.1 Sensor Node Execution Environment  
The execution environment is the responsible to run programs on top of the available hardware. The first systems had dedicated execution environments to make the best use of the available hardware heterogeneity. The presence of a memory management unit (MMU) can have a significant impact on the software update process. The MMU is the hardware component that manages virtual memory systems and, in most situations, it is included on the CPU chip. When the MMU is available, much of the code position is independent, because virtual memory addressing is used, adding safety boundaries to programs. Moreover, individual modules are executed as separate processes. Since processes run in a virtual address space, they can be easily upgraded at runtime without using references to absolute memory addresses. However, many of microcontrollers used on sensor nodes are not equipped with MMU. Without the MMU, a node operates in a single address space and, in such case, the node is  
Figure 3: Node remote reprogramming mechanisms.  
more vulnerable to incorrect or malicious memory references. Execution environments without MMU can be classified in monolithic environments, modular environments and virtual machines.  
In monolithic environments, the entire executable program is statically optimized during the compilation. In this case, a single system image containing both all applications and the system kernel is produced making efficient use of CPU and memory. The TinyOS operating system is an example of a monolithic execution environment. In such execution environments, a new complete image must be uploaded into the node, resulting in large update patches.  
In modular execution environments, individual modules can be independently loaded on demand. In this type of environment, the system is divided into two parts: the kernel, usually static, and the loadable component images, usually dynamic. The kernel provides services to the modules, such as memory management, I/O, and communications. The modules access the services provided by the kernel at predefined addresses or through a system jump table. The updates are smaller than in monolithic counterpart because the modules are separated from the kernel part. Moreover, the kernel part requires less frequent updates than in monolithic environment because it only provides the interfaces to the module applications. Contiki and Bertha operating systems use modular execution environments.  
Virtual machine (VM) environments are used to virtualize underlying hardware, providing high-level operations to applications through an instruction interpreter. VM typically executes a program in a sandbox where direct access to hardware is not allowed. In sensor networks, a VM environment also allows the implementation, by software, of some features that the hardware might not provide, such as the memory management unit. Unfortunately, VM introduces overhead in both execution time and memory resources. First, the runtime interpretation causes programs to run slower by at least an order of magnitude when compared with native execution. Second, the VM itself requires a certain fixed amount of memory to operate, and interpreted programs are generally more memory demanding. Several VM environments for TinyOS and Contiki operating systems were proposed, such as Mate and Agilla [45].