Stack size calculation

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Stack size calculation

    Hello everyone,

    I am working on LM3s5R31 controller. Embos version is 3.82K and IAR version is 6.3.

    I was finding out the stack size for tasks. EmbOS plugin shows used stack size but one thing I could not get. During idle time (normal working), used stack size for "Display Task" was 440 bytes. When controller does other operation, stack size increases to 560 bytes. I understand this thing as some extra routines are added. but when controller comes back in idle position (previous state), stack size does not come to 440 bytes and it remains at 560 bytes.

    Can anybody explain me why stack size is not coming to previous size?

    For stack size, I read the documents provided in embOS RTOS folder. But I want to understand If user function added, then how stack size increases?

    Regards,
    Harsh
  • Hello Harsh,

    the stack size is the maximum used stack size not the currently used!

    The actual stack size depends on how much sub functions are called because the return address is stored on the task stack.
    It also depends on how much local variables you use, they are also stored on the task stack.

    Best regards,
    Til
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.