Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

void  OSTaskStkChk (OS_TCB       *p_tcb,

...

                    CPU_STK_SIZE *p_free,

...

                    CPU_STK_SIZE *p_used,

...

                    OS_ERR       *p_err)

...

...

File

...

...

Called from

...

Code enabled by

...

...

os_task.c

...

...

Task only

...

OS_CFG_TASK_STAT_CHK_EN

...

10535661053566OSTaskStkChk() determines a task’s stack statistics. Specifically, it computes the amount of free stack space, as well as the amount of stack space used by the specified task. This function requires that the task be created with the OS_TASK_OPT_STK_CHK and OS_TASK_OPT_STK_CLR options. Anchor10535671053567

Stack sizing is accomplished by walking from the bottom of the stack and counting the number of 0 entries on the stack until a non-zero value is found. Anchor10633141063314

It is possible to not set the OS_TASK_OPT_STK_CLR when creating the task if the startup code clears all RAM, and tasks are not deleted (this reduces the execution time of OSTaskCreate()).

Anchor10059591005959µC/OS-III’s statistic task calls OSTaskStkChk() for each task created and stores the results in each task’s OS_TCB so your application doesn’t need to call this function if the statistic task is enabled. Anchor10059601005960

Arguments

Anchor10059611005961p_tcb Anchor10059631005963

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.

Anchor10059651005965p_freeanchor10059661005966

is a pointer to a variable of type CPU_STK_SIZE and will contain the number of free CPU_STK elements on the stack of the task being inquired about.

Anchor10633531063353p_usedanchor10633541063354

is a pointer to a variable of type CPU_STK_SIZE and will contain the number of used CPU_STK elements on the stack of the task being inquired about.

...

p_err Anchor10059721005972

is a pointer to a variable that will contain an error code returned by this function.

...

classWebWorks_Indent_1

...

...

OS_ERR_NONE

...

classWebWorks_Indent_2

...

...

if the call was successful.

...

...

OS_ERR_PTR_INVALID

...

classWebWorks_Indent_2

...

if OS_CFG_ARG_CHK_EN is set to 1 in os_cfg.h: if either p_free or p_used are NULL pointers.

...

...

classWebWorks_Indent_1

...

OS_ERR_TASK_NOT_EXIST

...

classWebWorks_Indent_2

...

if the stack pointer of the task is a NULL pointer.

...

...

OS_ERR_TASK_OPT

...

classWebWorks_Indent_2

...

if OS_OPT_TASK_STK_CHK is not specififed whencreating the task being checked.

...

classWebWorks_Indent_1

...

OS_ERR_TASK_STK_CHK_ISR

...

classWebWorks_Indent_2

...

if OS_CFG_CALLED_FROM_ISR_CHK_EN set to 1 in os_cfg.h: if calling this function from an ISR.

...

Returned Value

...

1005984None Anchor10504151050415

Notes/Warnings

...

Example

...

rowspan19

...