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.

MSP432P401R: TI-RTOS Task's stack memory allocation.

Part Number: MSP432P401R

Hello Community,

I'm working on a TI-RTOS based application. I just want to know from where the allocation of Task's Stack memory is done.

Is it allocated from a heap? Also, I can't see it under the Memory Allocation section in CCS.

Thanks,

Keshav Aggarwal 

  • Hi Keshav,

    You should be able to use the ROV feature in CCS. The Debugging Applications that use TI-RTOS Technical Overview includes other ways for checking the stack usage.

    Runtime Object View (ROV)

    How to use Runtime Object View

    Regards,

    James

  • Hello James,

    My query was not to check stack usage. Actually I want to know how the Task's Stack memory is allocated in TI-RTOS based application.

    Does it Allocate from the heap?

    Regards,

    Keshav Aggarwal

  • Hello Keshav,

    By default, the task stacks are allocated from .bss and not the heap. If you look at the .cfg for a code example in XGCONF inside CCS, you'll see that the heap size is NULL.

    Regards,

    James

  • Hello James,

    I have checked the .bss section. It's showing stack of 512 bytes.

    In fact I'm using 2 Tasks having below configs-

    /* Construct writer/reader Task threads */
        Task_Params_init(&taskParams);
        taskParams.stackSize = 2704;
        taskParams.priority = 2;
        task1ThreadHandle = Task_create((Task_FuncPtr)task1Thread, &taskParams, Error_IGNORE);
        if (task1ThreadHandle == NULL) {
            while (1);
        }
    
        Task_Params_init(&taskParams);
        taskParams.stackSize = 3272;
        taskParams.priority = 1;
        task2ThreadHandle = Task_create((Task_FuncPtr)task2Thread, &taskParams, Error_IGNORE);
        if (task2ThreadHandle == NULL) {
            while (1);
        }

    I don't know why it's showing 512 instead of 2704 and 3272

    Regards,

    Keshav Aggarwal

  • Hello James,

    I have checked TI-RTOS Object creation doc and found the line below-

    Dynamically Create: The application can “create” a kernel object. The API will always need a heap to allocate the object. All module creates require an Error_Block.

    So, it must be using heap to allocate stack.

    Thanks & Regards,

    Keshav Aggarwal

  • Keshav Aggarwal said:
    So, it must be using heap to allocate stack.

    If it's dynamically created, yes.

    Keshav Aggarwal said:
    I have checked TI-RTOS Object creation doc and found the line below-

    If it's statically created, then the heap will NOT be used. From the TI-RTOS Object creation doc:

    Statically Create: In the application’s .cfg file, you can “statically create” the kernel object. No heap is needed for statically allocated objects. The “filled-in” structure is added into the big generated source file.

    Keshav Aggarwal said:
    I don't know why it's showing 512 instead of 2704 and 3272

    I would assume the 512 stack size defined in the .cfg file limits whatever you specify by taskParams.stackSize parameter. Perhaps not ignoring errors (Error_IGNORE) in the Task_create() function would shed more light on this behavior too.

    Regards,

    James

**Attention** This is a public forum