...
Files
os.h/os_task.c
Prototype
Code Block |
---|
void OSTaskStkChk (OS_TCB *p_tcb,
CPU_STK_SIZE *p_free,
CPU_STK_SIZE *p_used,
OS_ERR *p_err) |
Arguments
p_tcb
is a pointer to the TCB of the task where the stack is being checked. A NULL
pointer indicates that the user is checking the calling task’s stack.
...
- Execution time of this task depends on the size of the task’s stack.
- The application can determine the total task stack space (in number of
CPU_STK
elements) by adding the value of*p_free
and*p_used
. This number should add up to the task’s stack size which is stored in the.StkSize
field of theOS_TCB
of the task. - The
#define
CPU_CFG_STK_GROWTH
must be declared (typically fromos_cpu.h
). When this#define
is set toCPU_STK_GROWTH_LO_TO_HI
, the stack grows from low memory to high memory. When this#define
is set toCPU_STK_GROWTH_HI_TO_LO
, the stack grows from high memory to low memory.
Example Usage
Code Block |
---|
OS_TCB MyTaskTCB;
void Task (void *p_arg)
{
OS_ERR err;
CPU_STK_SIZE n_free;
CPU_STK_SIZE n_used;
(void)&p_arg;
while (DEF_ON) {
:
:
OSTaskStkChk(&MyTaskTCB,
&n_free,
&n_used,
&err);
/* Check "err" */
:
:
}
} |