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.

RTOS/EK-TM4C1294XL: Access Other Tasks Information?

Part Number: EK-TM4C1294XL
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

In TI-RTOS, are there ways for a running task to get the other tasks' stack information, such as xdc_Ptr stack, stackSize, and sp, xdc_SizeT used when others are in Ready, or Blocked mode?  Thanks, 

  • Hi Neil,

    You can use Task_stat to get the following information about a task. Just supply the task handle you are interested in and a pointer to the following structure. Please refer to the SYS/BIOS API Reference (cdoc) for more information. 

    typedef struct Task_Stat {
        Int priority;
        // Task priority
        Ptr stack;
        // Task stack
        SizeT stackSize;
        // Task stack size
        IHeap_Handle stackHeap;
        // Heap used to alloc stack
        Ptr env;
        // Global environment struct
        Task_Mode mode;
        // Task's current mode
        Ptr sp;
        // Task's current stack pointer
        SizeT used;
        // Maximum number of bytes used on stack
    } Task_Stat;

    Todd

  • Thank you, Todd, following your advice, I have tried 2 hours looking for SYS/BIOS API Reference (cdoc)  in CCS, by googling, in Ti.com, unfortunately in vain.

    1. before submitting the question, I had found the Task_Stat structure and known it works in a running task by coding like:

    Task_stat(Task_self(), &statbuf); /* call func to get status */

    I guess Task_self() is supposed to return the task handler as you talked about. 

    I have no problem about the running task calls the Task_stat to get its own stack information.  My really questions are as follows: 

    2. As we know a task can be created by statically or dynamically.  For all created tasks, are their memory location fixed or changed by TI-RTOS during program running?  Why would I ask this question?  Because fixed location means that no matter the tasks in running mode, ready mode, blocked mode, inactive mode, or terminated mode, the information should be kept in the same location without erased by other code.  If the memory locations are changed as the OS swaps tasks in or out, then these information should be lost.  Please confirm this question.

    Thanks, 

    Neil

  • Hi Neil,

    The only scenario I can think of where a task's information moves or becomes unavailable is if the task is deleted with Task_delete or if you configure the kernel to automatically delete functions that have terminated. Otherwise, you should be able to safely call Task_stat with the task handle to get the information.

    Also, you can use Task createhooks to notify yourself when tasks are created so that you can store the new task handle somewhere to use later.

    Thanks,

    Sean

  • Thank you, Sean, for the confirmation and teaching.  In the example of mutex_EK_TM4C1294XL_TI, it works well.  Only got a warning message when using ti_sysbios_knl_Task_Struct * as the ti_sysbios_knl_Handle passed to Task_stat(&Task1_Struct, &statbuf) as follows: "../mutex.c", line 111: warning #169-D: argument of type "ti_sysbios_knl_Task_Struct *" is incompatible with parameter of type "ti_sysbios_knl_Task_Handle", but the program get the stat information correctly.