5.5.2 Endless-Loop Tasks
As with the structure of the application initialization task, the structure of an endless loop task can also contain initialization code. The endless loop's initialization code, however, only needs to be executed when the task first runs, after which the task executes in an endless loop, as shown in Listing 5.2.
The critical part of the design of an endless-loop task is the one or more blocking calls within the body of the loop. These blocking calls can result in the blocking of this endless-loop task, allowing lower priority tasks to run.
Listing 5.2: Pseudo code for an endless-loop task.
EndlessLoopTask ()
{
Initialization code
Loop Forever
{
Body of loop
Make one or more blocking calls
}
}