This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Task stack usage info in Task_stat from Task_Stat(): a little bug in the SYS/BIOS code?

Expert 1960 points
Other Parts Discussed in Thread: SYSBIOS

Hi, 

I tried to monitor stack usage by tasks during run time. In the RTOS kernel manual, there is some example code to do. It basically calls Task_Stat() function to return a data struct named Task_stat which contains fields named "used" and "stackSize". Both the example code and the online document for RTOS kernel say clearly the purpose of these two fields, ie. "used to give stack usage, and "stackSize" is for allowed stack size. But after I ran the code, it returns "used" as 0 and "stackSIze" as stack size used.  I was wondering if anyone else encountered the same issue. Do we have the source code for function "Task_Stat()" so maybe I can verify?

  • Hi Shef,

    Can you please let me know the version of the TI-RTOS, the example and the board that you are using? I will recreate the issue on my computer. From the documentation, the expected value for "used" field is the max number of words used on stack and "stackSize" is the size of Task stack.

    Regarding the source code, you can find it under <ti-rtos_dir>/products/<bios_??_??_??_??>/packages/ti/sysbios/knl/Task.c.

    Vikram

  • Thanks for your help. I'm using all the latest or at least trying to, SYS/BIOS 6.41 on F28377D controlCard. Both the document and source code task.c (thanks for the info too) suggest that statbuf.used should return stack size used, and stackSize as allocated stack. But I got used=0, and stackSize as changing number same as stackPeak as shown in ROV. I tried to use both Task_self() and the task handle to check the current running task, got the same result. Please let me know how it works on your side. Thanks again!
  • Hi Shef,

    How did you check the values? Are you printing them? If yes, then you need typecast the values.

    For ex:

    System_printf("used = %d, stackSize = %d\n", (int)ts.used, (int)ts.stackSize);

    The value of size_t is 32 bits where as int is 16 bits on C28x processors.   

    Vikram 

  • Vikram, you are exactly right! After I used the cast, it works fine now. Once again I overlooked the difference of data types!