Quality RTOS & Embedded Software

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




Loading

Stack memory Defragmentation ?

Posted by Sachin Bhujbal on July 25, 2008
Dear All,
I have one doubt about TaskCreate() & TaskDelete() functions. As per FreeRTOs source code when a task deletes, the memory block used by it is listed in a link list. When we creates a task, it first checks the available free blocks, checks the sizes of them & it uses those free blocks only if any block is having large size than required for that task. In this case there will be memory loss.
Is there any Defragmentation available in FreeRTOs ?
If anybody have any idea, please reply.
Thanks,
Sachin Bhujbal

RE: Stack memory Defragmentation ?

Posted by Dave on July 25, 2008
FreeRTOS uses pvPortMalloc and vPortFree instead of malloc and free. This means you can define whichever memory allocation scheme you want. If you are using heap_2.c and the tasks you create and delete always have the same stack size and there is no other random size memory allocation going on then you should not suffer from fragmentation as the same memory blocks will just get reused.

RE: Stack memory Defragmentation ?

Posted by Sachin Bhujbal on July 25, 2008
Dave,
Thanks for the Reply,
You have suggested a best thing, for small applications. But it is not possible to keep same stack size for all tasks in big applications because of RAM limitations.

RE: Stack memory Defragmentation ?

Posted by Sachin Bhujbal on August 11, 2008
Dear Dave,
What we will do is we kept two or three fixed stack sizes, high, medium, low.
And we will fit all the tasks in that three stack sizes as per requirement. So this is also benificial. Thanks for giving the clue of solution, Thank You Very Much.


[ 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