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] [February 2013 Threads] how to clean up deleted task 's resourcePosted by vincent on February 19, 2013 all:
i know that IDLE task is in charge of cleaning up deleted task's resource. however, IDLE task's priority is lower. it is possible that high priority task creates new task before IDLE task does it, if the FreeRTOS 's memory is lower, it may be fail to create new task. so, i wonder to know that there is a way to wake up IDLE task in running mode once one task is deleted ?
vincent
RE: how to clean up deleted task 's resourcePosted by Richard on February 19, 2013 First - it is very rare in small embedded systems that it is necessary to delete tasks. Generally in small dedicated systems all the resources (including tasks) are created during initialisation and then persist in the system until the system is turned off. You may therefore like to consider if there is an alternative to deleting the tasks in the first place.
Resources have to be cleaned by a task other than the task being deleted, hence it is done in the idle task. You could call the function used by the idle task to clean resources directly from another task, but that would require hacking the tasks.c file a bit as the function only has file scope.
If you really needed to you could temporarily raise the priority of the idle task (there is a function that allows you to get its handle) to the same priority as the task that wants to recreate a task - but be very careful doing that as the idle task never blocks so if you raise its priority too high you will not be able to recover and your application tasks will never run again.
Also, the function that creates a task returns a value that tells you if the task was created successfully or not, you could sit in a loop calling the xTaskCreate() function until it is successful if the only reason it is not successful is because a task that has been deleted has not yet been cleaned. Make sure to add a delay between each call to ensure the idle task has a chance to run though.
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|