Quality RTOS & Embedded Software

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




Loading

Task Cleanup

Posted by Jason on November 2, 2012
I am trying to understand what happens to a task when it returns (ends). The majority of my tasks are perpetual but I have a few that are 'one shot' tasks meaning they may do something, delay, do some more things then return. I noticed the following in one of the demo projects...

#define INCLUDE_vTaskCleanUpResources0


... but I can't find this documented anywhere.

Will the idle task clean up the resources used by the task that returns? Does it depend on the option above?



RE: Task Cleanup

Posted by Dave on November 2, 2012
According to http://www.freertos.org/History.txt vTaskCleanUpResources was obsolete and finally removed in V7.0.2.

A task must never return, but can be deleted, so if you want a task to "return" then add vTaskDelay(NULL) to the end of the function that implements it.

When you delete a task the TCB and stack will be freed by the idle task. The stack and TCB were allocated by FreeRTOS so it is right that they are also freed by FreeRTOS. FreeRTOS will not free any memory that the application allocated itself though, that must be cleaned manually.


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




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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

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

OpenRTOS and SafeRTOS