void OSTaskSuspend (OS_TCB *p_tcb,
OS_ERR *p_err)
File | Called from | Code enabled by |
---|---|---|
| Task only |
|
Description
OSTaskSuspend()
suspends (or blocks) execution of a task unconditionally. The calling task may be suspended by specifying a NULL
pointer for p_tcb
, or simply by passing the address of its OS_TCB
. In this case, another task needs to resume the suspended task. If the current task is suspended, rescheduling occurs, and µC/OS-III runs the next highest priority task ready-to-run. The only way to resume a suspended task is to call OSTaskResume()
.
...
The user can “nest” suspension of a task by calling OSTaskSuspend()
and therefore it is important to call OSTaskResume()
an equivalent number of times to resume the task. If suspending a task five times, it is necessary to unsuspend the same task five times to remove the suspension of the task.
Files
os.h/os_task.c
Prototype
Arguments
p_tcb
is a pointer to the TCB of the task the user is suspending. A NULL
pointer indicates suspension of the calling task.
...
If attempting to suspend the ISR handler task. This is not allowed since the ISR handler task is a µC/OS-III internal task.
Returned Value
None
Required Configuration
OS_CFG_TASK_SUSPEND_EN
must be enabled in os_cfg.h. Refer to uC-OS-III Configuration Manual
Callers
Application.
Notes/Warnings
OSTaskSuspend()
andOSTaskResume()
must be used in pairs.- A suspended task can only be resumed by
OSTaskResume()
.