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] [April 2014 Threads] Exact task stack sizePosted by shockwaver-one on April 13, 2014 Hello everyone.
I was wandering how to calculate the exact (or closest to it) stack size I should pass to the xTaskCreate macro function. Is it the sum of all the bytes required by the task function viariables or is there more?
Thanks in advance.
Exact task stack sizePosted by bowerymarc on April 13, 2014 Hard to do, because it's not just those variables but any stack used by any other functions called by the taskā¦. usually you do it empirically with high water marks (or crash/hangs!)
Also be aware of alignment for the processor - e.g. on an ARM, an 8 bit variable still takes up 4 bytes of stack.
On Apr 13, 2014, at 1:22 PMEDT, Shockwaver wrote:
Hello everyone.
I was wandering how to calculate the exact (or closest to it) stack size I should pass to the xTaskCreate macro function. Is it the sum of all the bytes required by the task function viariables or is there more?
Thanks in advance.
Exact task stack size
Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/freertos/discussion/382005/
To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/
Exact task stack sizePosted by shockwaver-one on April 13, 2014 Thanks for the reply.
Well then it comes to me if there is a way to calculate the size of the stack of a function. Variables used + ... ?
Exact task stack sizePosted by rtel on April 13, 2014 The stack is managed by the compiler, not FreeRTOS. If you have a C function that, when called from main() takes 'n' bytes of stack space, then when you call the function from a FreeRTOS task it will still take 'n' bytes of stack space.
How big 'n' is depends on the architecture you are using, the compiler you are using, the optimisation level you set for the compiler, etc. etc.
As already mentioned, the easiest/normal way of doing it is to set a stack size you think is big enough, then turn on stack overflow checking. If the overflow hook is called you know the stack was not large enough. If the overflow hook was not called then you can call uxTaskGetStackHighWaterMark() to see how much space remains unused.
Regards.
Exact task stack sizePosted by shockwaver-one on April 13, 2014 Thanks for the reply.
Fine by me then, I'll go empirically.
Thank you again.
Exact task stack sizePosted by alainm3 on April 13, 2014 I have been testing the stack overflow hook and most of the time I got an exception intead of a warning. The reason is that if it is a relatively big stack overflow it will crash befor being detected.
But I have adapted the afore mentioned function throu my serial debug output and it is really very helpfull. After runing and exercising the sistem I could adjust all my different stacks!
Exact task stack sizePosted by wella on April 14, 2014 Are you using GCC compiler? If yes, try to use the -fstack-usage parameters. The compiler will generate stack usage for your source code, resp. every function. Unfortunately not for the standard library. By generating a function call-tree you can estimate the stack usage of your functions in andvance.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|