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
  • Hello,

    I have a DEBUGPrintf() function in my project that uses the vsprintf() function.

    int DEBUGPrintf(const char *szFmt, ...)
    {
    
      char s[200];
      va_list vlArgList;
      va_start(vlArgList, szFmt);
      vsprintf(s, szFmt, vlArgList);
      va_end(vlArgList);
      DEBUGPuts(s);
      return (0);
    }
    

    The vsprintf() function is the source of the 'Unknown Stack Size' problem.
    1) Does anyone know another way to implement such print function without using vsprintf()?
    2) Does anyone know why the vsprintf() function causes this undefined stack usage?

    Thanks
    André Moutinho

Reply
  • Hello,

    I have a DEBUGPrintf() function in my project that uses the vsprintf() function.

    int DEBUGPrintf(const char *szFmt, ...)
    {
    
      char s[200];
      va_list vlArgList;
      va_start(vlArgList, szFmt);
      vsprintf(s, szFmt, vlArgList);
      va_end(vlArgList);
      DEBUGPuts(s);
      return (0);
    }
    

    The vsprintf() function is the source of the 'Unknown Stack Size' problem.
    1) Does anyone know another way to implement such print function without using vsprintf()?
    2) Does anyone know why the vsprintf() function causes this undefined stack usage?

    Thanks
    André Moutinho

Children