OSTaskResume
Description
Resumes a task suspended through the OSTaskSuspend()
function. In fact, OSTaskResume()
is the only function that can unsuspend a suspended task. Obviously, the suspended task can only be resumed by another task. If the suspended task is also waiting on another kernel object such as an event flag, semaphore, mutex, message queue etc., the suspension will simply be lifted (i.e., removed), but the task will continue waiting for the object.
The user can “nest” suspension of a task by calling OSTaskSuspend()
and therefore must call OSTaskResume()
an equivalent number of times to resume such a task. In other words, 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
void OSTaskResume (OS_TCB *p_tcb, OS_ERR *p_err)
Arguments
p_tcb
is a pointer to the TCB of the task that is resuming. A NULL
pointer is not a valid value as one cannot resume the calling task because, by definition, the calling task is running and is not suspended.
p_err
is a pointer to a variable that will contain an error code returned by this function.
OS_ERR_NONE
If the call was successful and the desired task is resumed.
OS_ERR_OS_NOT_RUNNING
If OS_CFG_INVALID_OS_CALLS_CHK_EN
is set to DEF_ENABLED
in os_cfg.h
: if µC/OS-III is not running yet.
OS_ERR_STATE_INVALID
If the task is in an invalid state.
OS_ERR_TASK_NOT_SUSPENDED
If the task attempting to be resumed is not suspended.
OS_ERR_TASK_RESUME_ISR
If OS_CFG_CALLED_FROM_ISR_CHK_EN
set to DEF_ENABLED
in os_cfg.h
: if calling this function from an ISR.
OS_ERR_TASK_RESUME_SELF
If OS_CFG_ARG_CHK_EN
is set to DEF_ENABLED
in os_cfg.h
: if passing a NULL
pointer for p_tcb
or, a pointer to the current TCB. It is not possible to resume the calling task since, if suspended, it cannot be executing.
Returned Value
None
Required Configuration
OS_CFG_TASK_SUSPEND_EN
must be enabled in os_cfg.h
. Refer to µC-OS-III Configuration Manual.
Callers
Application.
Notes/Warnings
None
Example Usage
OS_TCB TaskY; void TaskX (void *p_arg) { OS_ERR err; while (DEF_ON) { : : OSTaskResume(&TaskY, &err); /* Resume suspended task */ /* Check "err" */ : : } }