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] [March 2008 Threads] Ensuring idle task runs after vTaskDeletePosted by JC on March 13, 2008 If one wanted to restart a task by deleting it with vTaskDelete() followed by xTaskCreate(), is there a way to ensure the idle task gets run to clean up between the calls?
In this particular situation, I have a task that initializes a handful of variables at startup which control which of two devices the driver talks to. The user can flip a switch to change which device is used. The cleanest method at this particular time is to have the main control task stop and restart the driver task. I just need (I think) to make sure the idle tasks gets run to clean up the TCBs and such.
Thanks, --jc
RE: Ensuring idle task runs after vTaskDeletePosted by David Hawks on March 14, 2008 Here are some ways:
- Have the idle task create the driver task if it has been deleted. - Have the idle task send a message to your main control task when it detects that the driver task has been deleted. - Have the idle task give a semaphore every time it runs and have the main control task pend on the semaphore after deleting the driver task.
The last method is the most generic, but it does add extra overhead to the idle task.
RE: Ensuring idle task runs after vTaskDeletePosted by JC on March 14, 2008 The last idea was the one I had already come up with, but I was hoping there was a less hackish way of doing this.
It would seem that if vTaskDelete() and xTaskCreate() are being used, there should be some way of enforcing the clean up. Yes, sooner or later the idle task will run, but guaranteeing when is more difficult.
--jc
RE: Ensuring idle task runs after vTaskDeletePosted by David Hawks on March 14, 2008 The idle task calls the static function prvCheckTasksWaitingTermination() to finish deleting tasks. Perhaps you could make this public and call it after you call vTaskDelete(). You must be careful not to do this from the task you deleted, though. Of course, you're not sticking to the API if you do this, but it is a more elegant solution.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|