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.

Stack of task

Other Parts Discussed in Thread: SYSBIOS

Hi, Everyone

I have a question.
We use SYS/BIOS on AM335x.

When generating dynamic tasks,
Is it possible to allocate stack of task from stack memory area ?

We wanna know how much size of stack memory we can allocate,
when generating tasks.

Do you have any idea ?

Best Regards
Hiroyasu

  • Hiroyasu,

    If you want to provide pre-allocated memory for a Task to use for its stack, you can specify this memory via the “stack” and “stackSize” parameters in the Task_Params structure passed to Task_create().

    For example, substituting your address for MYMEM, and the size for MYSIZE:

    Task_Params taskParams;
    Task_Params_init(&taskParams);
    taskParams.stack = MYMEM;
    taskParams.stackSize = MYSIZE;
    task0 = Task_create((Task_FuncPtr)myTask, &taskParams, null);

    Internally in Task_create(), there will be a check to see if the memory block is properly aligned, and if not, the addresses will be tweaked to force the alignment.  You can see what is exactly done by looking at the kernel source code in your installation (look for “Task_Instance_init()” if the file …\bios_6_xx_yy_zz\packages\ti\sysbios\knl\Task.c)

    If you want this memory to come from the system stack, then you will need to take care of allocating enough space for this on the system stack, and then allocating specific blocks for the Task stacks from this.  Normally Task stacks are allocated from heaps, and there is no direct support for allocation from the system stack.

    Regards,
    Scott

  • Hi, Scott

    Thank you for your reply.
    I got it.

    Best Regards
    Hiroyasu