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



Posted by yukunduan on October 13, 2015

When I created a task,the task created and run success.Then It,s delete itself. But when i created it again,the xTaskCreate function return errCOULDNOTALLOCATEREQUIREDMEMORY. So ,I think the problem is that I delete the function without free memory. So,How to free the "usStackDepth" memory ? And i see the task vTaskDelete description:The idle task is responsible for freeing the RTOS kernel allocated memory from tasks that have been deleted. So it means the idle task not be executed in my project?


Posted by richard_damon on October 13, 2015

That is possible, do you have some task that doesn't block, but sits in a polling loop? That will keep the idle task from running as you never give it a chance. (Note, calling taskYield() will NOT let a lower priority task run, only tasks of the same priority, this is a common misconception).

It is also possible that your heap has gotten fragmented by other allocations, blocking the new allocation from succeeding.

I rarely delete tasks, if I am going to need them again, I have them do their work, and then wait on something (queue/semaphore) to tell them to do their work again, as it can be difficult to code in the chances of tasks not being able to be created due to heap exhaustion/fragmentation (I normally try to have NO usage of the heap once the system is up and operational).


Posted by yukunduan on October 13, 2015

Thanks for your answer. I have solved the problem. 1.add micro blow in FreeRTOSConfig.h define #define INCLUDE_xTaskGetIdleTaskHandle 1 2.Because one task never be in wait except high task run.So the idle task never run.so i add taskDelay function in it. It,s indeed to free memory by calling idle task. Oh, I quite agree with your point about the task deleting.I will consider to change my code.Thank you.


Posted by yukunduan on October 13, 2015


Posted by richard_damon on October 13, 2015

Your 1. isn't needed, it enables the creationg of a function xTaskGetIdleTaskHandle() to get the handle used for the IdelTask (perhaps to get run-time stats on it).

My general rule is any task that doesn't naturally have a block for something, (and thus will try to run continiously) should be at the Idle priority (0), and thus will share time with the Idle task. These sort of tasks are generally fairly rare, and are mostly background cleanup tasks (Like Idle is for FreeRTOS).

[ 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