...
void OSTaskDel (OS_TCB *p_tcb,
...
OS_ERR *p_err)
...
File |
---|
...
Called from |
---|
...
...
Code enabled by |
---|
...
...
|
...
...
Task only |
...
|
...
When a task is no longer needed, it can be deleted. Deleting a task does not mean that the code is removed, but that the task code is no longer managed by µC/OS-III. OSTaskDel()
can be used when creating a task that will only run once. In this case, the task must not return but instead call OSTaskDel((OS_TCB *)0, &err) which
specifies to µC/OS-III to delete the currently running task.
Anchor
OSTaskDel()
the address of the OS_TCB
of the task to delete.Once a task is deleted, its OS_TCB
and stack may be reused to create another task. This assumes that the task’s stack requirement of the new task is satisfied by the stack size of the deleted task.
Anchor
Arguments
...
p_tcb
is a pointer to the TCB of the task to delete or, you can pass a NULL
pointer to specify that the calling task delete itself. If deleting the calling task, the scheduler will be invoked so that the next highest-priority task is executed.
...
p_err
is a pointer to a variable that will receive an error code:
...
class | WebWorks_Indent_1 |
---|
...
OS_ERR_NONE
...
class | WebWorks_Indent_2 |
---|
...
...
'p_err' gets set to OS_ERR_NONE
before OSSched()
to allow the returned error code to be monitored (by another task) even for a task that is deleting itself. In this case, p_err
must point to a global variable that can be accessed by that other task and, you should initialize that variable to OS_ERR_TASK_RUNNING
prior to deleting the task.
...
class | WebWorks_Indent_1 |
---|
...
OS_ERR_TASK_DEL_IDLE
...
class | WebWorks_Indent_2 |
---|
...
If attempting to delete the idle task.
...
class | WebWorks_Indent_1 |
---|
...
...
OS_ERR_TASK_DEL_ISR
...
class | WebWorks_Indent_2 |
---|
...
If OS_CFG_CALLED_FROM_ISR_CHK_EN
set to 1
in os_cfg.h
: if you called OSTaskDel()
from an ISR.
...
...
OS_ERR_TASK_DEL_INVALID
...
class | WebWorks_Indent_2 |
---|
...
If attempting to delete the ISR Handler task while OS_CFG_ISR_POST_DEFERRED_EN
is set to 1.
...
Returned Value
...
None Anchor
Notes/Warnings
...
...
OSTaskDel()
verifies that the user is not attempting to delete the µC/OS-III idle task and the ISR handler task.
...
- Be careful when deleting a task that owns resources.
...
Example
...
rowspan | 14 |
---|
...