This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Help adjusting task stack size

Hello all,

I need to free more RAM memory in my application so the first thing will be reducing (optimizing) the task stack sizes.

I have created a check task that verify each stack area magic number and indicate the stack usage worst case. I run some test scenario and then adjust the stack sizes based on this worst case values.

I also tried to use the keil syntactic analyser (the htm file generated after compilation). This file gives me information concerning the stack usage of each task such as:

[Stack]
Max Depth = 624 + Unknown Stack Size

I have noticed that the real memory usage for each task is higher than the value indicated by the HTM file. If I set the stack memory as indicated by the HTM I get the stack overflow exception. So I adjusted the stack memory in a trial and error manner. But this is risky and demands much tests.

Does anyone can give me some advice on a better method to get the safer/optimized stack size value and how can I predict the "Unknown Stack Size" found in the HTM file?

Thanks
Andre Moutinho

Parents
  • I run some test scenario and then adjust the stack sizes based on this worst case values.

    That plan is doomed to fail because those are not, actually, known to be the worst-case value values. They're just the worst case encountered during the particular tests you happened to run.

    how can I predict the "Unknown Stack Size" found in the HTM file?

    Most probably you can't. Nobody can, in the general case. What you can often do instead is avoid putting sources of unknown stack consumption into your program in the first place. The usual candidates are function pointers, recursion and any kind of assembly code.

Reply
  • I run some test scenario and then adjust the stack sizes based on this worst case values.

    That plan is doomed to fail because those are not, actually, known to be the worst-case value values. They're just the worst case encountered during the particular tests you happened to run.

    how can I predict the "Unknown Stack Size" found in the HTM file?

    Most probably you can't. Nobody can, in the general case. What you can often do instead is avoid putting sources of unknown stack consumption into your program in the first place. The usual candidates are function pointers, recursion and any kind of assembly code.

Children