TI中文支持网
TI专业的中文技术问题搜集分享网站

cc1310 任务栈的大小

请问如果我需要创建多个任务,能不能共用一个TASK_STACK,还是说一个任务使用一个栈,还有就是栈的大小是要根据什么定的

YiKai Chen:

一个任务使用一个栈、建議你參考一下 dev.ti.com/…/

Susan Yang:

附上栈溢出的检测方法

Task_Stat statbuf; /* declare buffer */
Task_stat(Task_self(), &statbuf); /* call func to get status */
if (statbuf.used > (statbuf.stackSize * 9 / 10)) {System_printf("Over 90% of task's stack is in use.\n");
}

Susan Yang:

另外借用 e2e.ti.com/…/197211 的回答

A. A task’s stack is allocated when the task is created.

Yes, a task’s stack holds context for the task execution.When a task is preempted by another task, or if the task blocks (for example, with a SEM_pend()), then the task’s context is *maintained* on its stack until the task executes again.

A task can use both global variables (that aren’t maintained in the task’s stack), or it can use task-local variables, that are maintained on the task’s stack.

B. The context on the task's stack is local variables for the task’s function, as well as the execution stack for any other functions that the task’s function calls.

C. As you call functions they will consume space on the task’s stack.If you call them one at a time, the task stack depth will rise/fall for each function call.If you have functions that call other functions, the depth will increase with each nested function call.The space required for each task can vary, and can be specified during task creation.Usually a larger stack size will be allocated to begin with, and then tuned downward later in development as stack size requirements are determined.

赞(0)
未经允许不得转载:TI中文支持网 » cc1310 任务栈的大小
分享到: 更多 (0)