Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

how to clean up deleted task 's resource

Posted 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 resource

Posted 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.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists