FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [September 2009 Threads] Best method to stop a busy-waiting task?Posted by Dennis Tan on September 4, 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); }
RE: Best method to stop a busy-waiting task?Posted by Richard on September 4, 2009 Is whatever it is busy waiting for capable of generating an interrupt? If so then have the task block on a semaphore and the interrupt unblock the task using the same semaphore.
If what it is busy waiting for is coming from another task then use a queue or semaphore to block again again, but this time have the other task send to the queue or semaphore to unblock the first task.
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|