void OSTaskCreate (OS_TCB *p_tcb,
CPU_CHAR *p_name,
OS_TASK_PTR p_task,
void *p_arg,
OS_PRIO prio,
CPU_STK *p_stk_base,
CPU_STK_SIZE stk_limit,
CPU_STK_SIZE stk_size,
OS_MSG_QTY q_size,
OS_TICK time_quanta,
void *p_ext,
OS_OPT opt,
OS_ERR *p_err)
File | Called from | Code enabled by |
---|---|---|
| Task or startup code | N/A |
Description
Tasks must be created in order for µC/OS-III to recognize them as tasks. You create a task by calling OSTaskCreate()
and by providing arguments specifying to µC/OS-III how the task will be managed. Tasks are always created in the ready-to-run state.
Tasks can be created either prior to the start of multitasking (i.e., before calling OSStart()
), or by a running task. A task cannot be created by an ISR. A task must either be written as an infinite loop, or delete itself once completed. If the task code returns by mistake, µC/OS-III will terminate the task by calling OSTaskDel((OS_TCB *)0, &err))
. At Micrium, we like the “while (DEF_ON)
” to implement infinite loops because, by convention, we use a while
loop when we don’t know how many iterations a loop will do. This is the case of an infinite loop. We prefer to use for
loops when we know how many iterations a loop will do.
Files
os.h/os_task.c
Prototype
Task as an infinite loop:
...