Delay Polling

while(1)
{
    CheckButtons();
    OSDelay(50);
}

Delay Polling Task

void delay_polling_task()
{
    while(1)
    {
        CheckEnv();
        SetFlags();
        OSDelay(1);
    }
}

Wait and Run

bool isRunning = true;

while(1)
{
    OSSemPend(GoSem);
    while(isRunning)
    {
        PlayMusic();
    }
}
  • Simple pattern for controlling a loop.
  • The pend makes the loop wait until its signaled.
  • The boolean isRunning breaks the loop. Loop goes back to waiting.
  • isRunning should be set to TRUE before signaling the semaphore.

Table Of Contents

Previous topic

Re-entrant Code

Next topic

Signaling

This Page