## 3 Memory Management in MIROS
### Performance Evaluation  
In Figure 10 and Table 4, the code size, the execution efficiency and the memory utilization efficiency of the different dynamic allocators are evaluated. In Table 4, the symbol \(F\) represents the steps of searching for a free block in the Contiki SFL allocator (Contiki SFL uses the block flag mechanism other than the free list mechanism to manage the free memory), \(L\) represents the steps of searching for an available entry in the free list, and \(S\) represents the size of the memory to be shifted during the coalescing operation. Figure 8: MIROS proactive defragmentation _SF_ allocation. After \(B\) is de-allocated in Figure 8a, the \(C\) will be assembled with \(A\) proactively. Thus, no fragments will appear and the free memory space is continuous. Figure 9: MIROS reactive defragmentation sequential fit allocation. If a 20-byte object needs to be allocated in Figure 9a, the defragmentation operation is not needed. However, if a 40-byte object \(E\) needs to be allocated, the defragmentation operation will be performed (Figure 9b), as there is not enough continuous free memory in this case. From these evaluation results, it can be concluded that the code size and the allocation overhead of the dynamic allocators are not very high, thus the dynamic allocation approach is feasible to be used even on the resources-constrained WSN platforms. This result has also been proved in the article [23]. In this article, the authors insisted that the costs of the dynamic allocation are simply overestimated. Different allocation mechanisms have different strong points and weak points, and they strike the tradeoff among the allocation response time, the execution overhead and the memory utilization efficiency. The allocation response time is concerned with the real-time performance, the execution overhead is concerned with the energy cost, and the memory utilization efficiency is concerned with the memory constraint problem. As for which approach should be selected, it depends on the practical contexts. If the memory resource on the WSN platform is not highly constrained (e.g., the SunSPOT node which has 512 KB RAM) and the real-time tasks exist in the system (e.g., the periodic signal sampling tasks), the MIROS SFL approach can be an ideal choice. This is because the SFL approach has fast allocation response time and low allocation and de-allocation overhead, thus the real-time requirements can be better satisfied and it will cost fewer energy resources. However, if the memory resource on the nodes is precious (e.g., the Mica2 node with only 4 KB RAM) and the application  
\begin{table}
\begin{tabular}{|c|c|c|c|c|c|c|c|} \hline \multirow{3}{*}{**Allocation Mechanism**} & \multirow{3}{*}{**Allocation Status**} & \multicolumn{4}{c|}{**Execution Efficiency**} & \multirow{3}{*}{**Fragments (Internal or External)**} \\ \cline{3-4} \cline{6-8}  & & **Allocation** & & & **De-Allocation** & **(Internal or External)** & **Utilization** \\ \cline{3-4} \cline{6-8}  & & **Clock Cycles** & **Cost** & **Clock Cycles** & **Cost** & **External)** & **Efficiency** \\ \hline Contiki _SFL_ & \multirow{3}{*}{N/A} & 23 + 12*\(F\) & Low & 26 + 10*\(F\) & Low & External & Low \\ \hline SOS _SFL_ & \multirow{3}{*}{N/A} & 34 & Low & 38 & Low & Both exist & Low \\ \cline{3-4} \cline{6-8} MantisOS _SF_ & & 52 + 15*\(L\) & Medium & 37 + 16*\(L\) & Medium & External & Medium \\ \hline \multirow{3}{*}{MIROS _SFL_ (heap-extendable)} & Regular & 36 & Low & 32 & Low & & \\ \cline{3-4} \cline{6-8}  & In & \multirow{3}{*}{45 + 16*\(L\)} & \multirow{3}{*}{Medium} & \multirow{3}{*}{43 + 18*\(L\)} & \multirow{3}{*}{Medium} & \multirow{3}{*}{External} & \multirow{3}{*}{Medium} \\ \cline{3-4} \cline{6-8}  
tasks have a loose requirement to the real-time guarantee (e.g., the precise agricultural application in which the nodes only need to sample the environmental data several times a day and transmit the sensing packets to the base station), the MIROS reactive SF approach can be used.