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] [September 2009 Threads] Task stack size?Posted by Bill Yang on September 2, 2009 Hi,
Does any one know how to determine a stack size when I create a task? Or tell me what factors need to be consider for calculating a task stack size? I have read it from FreeRTOS web stie, but I am still not clear how. I used the demo of Cortex_LM3Sxxxxx_Keil. I tried to figure out how the demo does to determine a stack size. For example, the default configMINIMAL_STACK_SIZE is 70, but I modified it to 250. I wonder if it is a proper setting.
Also the mainBASIC_WEB_STACK_SIZE for uIP web server was set to configMINIMAL_STACK_SIZE * 3 which the original was 70*3=210. However, since I modified to 250, now it is 250*3=750. Is it waste memory space?
Any help will be appreciated.
RE: Task stack size?Posted by William Deninger on September 2, 2009 As you know, the stack size is determined during the creation of the task. Determining stack size has never been an automated process. For instance, FreeBSD has a default of 64MB stack for each application thread, and RedHat has 10MB user, and 8kB kernel, etc... Generally, you should estimate the required stack space for each thread. If you do have any recursive calling code within your task, you will need to program them for a maximum recursion depth.
FreeRTOS does have a compile mode supporting stack overflow detection, and I plan on having it compiled in automatically with the DEBUG build.
-W
RE: Task stack size?Posted by incrediball on September 2, 2009 You can also use the uxTaskGetStackHighWaterMark function to determine how much stack has actually been used and fine tune it. Important is that interrupts also use the stack of the task that is interrupted (although I'm not sure if all ports do this) so their usage needs to be added to the task's own usage.
RE: Task stack size?Posted by William Deninger on September 2, 2009 Just remember that in FreeRTOS, the stack size is specified as an unsigned portSHORT, which generally means 65535 words max. -W
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|