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] [June 2011 Threads] HEAP utilizationPosted by Anu123 on June 16, 2011 Hi,
Can anyone explain the relationship among the following three. 1. configTOTAL_HEAP_SIZE defined in FreeRTOSConfig.h
2. STACK_SIZE given when creating a task using xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
3. Min Free Stack value given by the FreeRTOS state viewer Tasks during debugging with IAR
I am using STM32L
Thank you.
RE: HEAP utilizationPosted by Richard on June 16, 2011 See http://www.freertos.org/a00111.html for configTOTAL_HEAP_SIZE and how task stacks use it. Also, but less useful http://www.freertos.org/a00110.html
http://www.freertos.org/a00125.html gives the prototype for the xTaskCreate() function, and says how stack sizes are specified. The stack is allocated from the heap as per the first link above.
The minimum free stack size is I think explained in the application note that comes with the IAR plug-in, but is the same as described here: http://www.freertos.org/uxTaskGetStackHighWaterMark.html
Regards.
RE: HEAP utilizationPosted by Anu123 on June 16, 2011 Thanks for your immediate reply Richard.
Still having problems and needs clarifications.
My RAM is 10KBytes. From that 1KB has to be reserved for the CSTACK.
13 tasks are created in my application. Total of 3328 bytes are allocated for the stack size of those tasks during xTaskCreate() function calls. Each task was given different stack sizes so that they will not have excess memory. (All having less than 100 minimum free stack each)
According to the map file the aggregation of RAM of all other files are around 1Kbytes.
Total of all above is (1K + 3.3K + 1K) 5.3K. However we cannot run the system with configTOTAL_HEAP_SIZE less than 8Kbytes.
Please explain what happens to the (8K - 5.3K) RAM, which is not used by my files/functions.
Note that I am using heap_2.c
Regards.
RE: HEAP utilizationPosted by Dave on June 16, 2011 Do you really need the CSTACK once the tasks have started? CSTACK is normally used by main(), but after the scheduler has started each tasks have their own stacks and CSTACK is not required any more. You can then recycle CSTACK for other uses, and normally find its start address from the variables defined in the linker script. If that is the case or not depends on the port and microcontroller you are using. Some ports reuse CSTACK as an interrupt stack.
RE: HEAP utilizationPosted by Dave on June 16, 2011 I was a bit hot on the add reply button there...
You cannot magic more RAM into a microcontroller, but you can select one from the same family that has more unless minimum recurring production code is really vital. However, another thing to consider is if you can cut down the number of tasks you have running. If some of the tasks perform periodic or run to completion functionality then you could implement them as timer callback functions instead of a task. All timer callbacks use the same stack as the timer task. If you can implement two tasks as timer callback functions, but add the timer task, overall you have still saved one entire stack of RAM.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|