## 3 Survey Results
### Task Scheduling  
Table 15 describes deployment task scheduling attributes: time sensitivity and the need for preemptive task scheduling. Two basic scheduling approaches do exist: cooperative and preemptive. In the former case, the switch between tasks is explicit--one task yields a processor to another task. A switch can occur only in predefined code lines. In the latter case, the scheduler can preempt any task at any time and give the CPU to another task. A switch can occur anywhere in the code. \begin{table}
\begin{tabular}{l l l l l} \hline \hline
**Nr** & **Codename** & \
\begin{tabular}{l} **Time sensitive** \\ **app-level tasks** \\ \end{tabular} &
\begin{tabular}{l} **Preemptive** \\ **needed** \\ \end{tabular} & **scheduling** \\ \hline
1 & Habitats & 0 & n &
\begin{tabular}{l} sense + cache + send in every period \\ complicated localization, network awareness and cooperation \\ \end{tabular} \\
2 & Minefield & 7+ & y &
\begin{tabular}{l} consider + cache + send in every period \\ complicated localization, network awareness and cooperation \\ \end{tabular} \\
3 & Battlefield & 0 & n & \\
4 & Line in the sand & 1? & n & \\
5 & Counter-sniper & 3? & n &
\begin{tabular}{l} localization, synchronization, blast detection \\ \end{tabular} \\
6 & Electro-shepherd &? &? & \\
7 & Virtual fences &? & n & \\
8 & Oil tanker & 1 & y &
\begin{tabular}{l} user-space cluster node discovery and sync are time critical \\ \end{tabular} \\
9 & Enemy vehicles & 0 & n & \\
10 & Trove game & 0 & n & \\
11 & Elder RFID & 0 & n & \\
12 & Murphy potatoes & 0 & n & \\
13 & Firewanet & 1 & y &
\begin{tabular}{l} sensing can take up to 200 ms; should be preemptive \\ \end{tabular} \\
14 & AlarmNet & 0 & n & - \\
15 & Ecuador Volcano & 1 & y &
\begin{tabular}{l} sensing is time-critical, but it is stopped, when the query is received \\ \end{tabular} \\
16 & Pet game & 0 & n & \\
17 & Plug & 0 & n & \\
18 & B-Live & 0 & y & \\
19 & Biomotion & 0 & y & \\
20 & AID-N & 0 & n & \\
21 & Freighting & 0 & n & \\
22 & Rehabil &? &? & \\
23 & CargoNet & 0 & n & \\
24 & Fence monitor & 0 & n & \\
25 & BikeNet & 1 & y & \\
26 & BriMon & 0 & n & \\
27 & IP net & 0 &? & \\
28 & Smart home &? &? & \\
29 & SVATS & 0 & y & \\
30 & Hitchhiker & 0 & y & \\
31 & Daily morning & 0 & n & \\
32 & Heritage & 1 & y & \\
33 & AC meter & 0 & n & \\
34 & Coal mine & 0 & n & \\
35 & ITS & 0 & n & \\
36 & Underwater & 0 & y & preemption needed for time sync and TDMA MAC \\
37 & PipeProbe & 0 & n & no MAC; just send \\
38 & Badgers & 0 & n & \\
39 & Helens volcano & 0 & y & preemption needed for time sync and MAC \\
40 & Tunnels & 0 & n & \\ \hline \hline \end{tabular}
\end{table} 
Table 15: Deployments: task scheduling. The main advantage of cooperative scheduling is resource efficiency: no CPU time and memory are wasted to perform periodic switches between concurrent tasks, which could be executed serially without any problem. The main advantage of preemptive scheduling is that users do not have to worry about task switching--it is performed automatically. Even if the user has created an infinite loop in one task, other tasks will have access to the CPU and will be able to execute. Preemptive scheduling can introduce new bugs, though; it requires context switching, including multiple stack management. Memory checking and overflow control is much harder for multiple stacks, compared to cooperative approaches with a single stack. If we assume that the user written code is correct, preemptive scheduling is required only in cases where at least one task is time-sensitive and at least one other task is time-intensive (it can execute for a relatively long period of time). The latter may disturb the former from handling all important incoming events. Twenty percent of analyzed deployments have at least one time-sensitive application layer task (most of them have exactly one), while 30% of deployments require preemptive scheduling.