dennistan wrote on Friday, September 04, 2009:
Hi:
If I have two tasks and one task (B) is doing a busy wait operation. What is the best method to stop the busy-waiting task from another task (A)?
I have presented two possibilities and if you know the pro and con of each please let me know. Also if you have a better method, please also let me know.
Dennis
Method 1:
Task B
{
while (1)
{
xSemaphoreTake
if (g_stop_request == true)
break;
xSemaphoreGive
vTaskDelay(1);
}
}
Task A
{
// At certain time
xSemaphoreTake
g_stop_request = true;
xSemaphoreGive
}
Method 2:
Task B
{
while (1)
{
if (xQueueReceive(qhandle, 0) == PD_True)
break;
vTaskDelay(1);
}
Task A
{
// At certain time
xQueueSend(qhandle, 0);
}