UINT32 LOS_TaskCreate ( UINT32 puwTaskID,
TSK_INIT_PARAM_S pstInitParam  
)

Create a task.

Description:
This API is used to create a task. If the priority of the task created after system initialized is higher than the current task and task scheduling is not locked, it is scheduled for running. If not, the created task is added to the queue of ready tasks.
注意:
  • During task creation, the task control block and task stack of the task that is previously automatically deleted are deallocated.
  • The task name is a pointer and is not allocated memory.
  • If the size of the task stack of the task to be created is 0, configure LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE to specify the default task stack size.
  • The task stack size must be aligned on the boundary of 8 bytes. The size is determined by whether it is big enough to avoid task stack overflow.
  • Less parameter value indicates higher task priority.
  • The task name cannot be null.
  • The pointer to the task executing function cannot be null.
  • The two parameters of this interface is pointer, it should be a correct value, otherwise, the system may be abnormal.
参数:
参数名称 描述
puwTaskID  [OUT] Type UINT32 * Task ID.
pstInitParam  [IN] Type TSK_INIT_PARAM_S * Parameter for task creation.
返回值:
返回值 描述
LOS_ERRNO_TSK_ID_INVALID  Invalid Task ID, param puwTaskID is NULL.
LOS_ERRNO_TSK_PTR_NULL  Param pstInitParam is NULL.
LOS_ERRNO_TSK_NAME_EMPTY  The task name is NULL.
LOS_ERRNO_TSK_ENTRY_NULL  The task entrance is NULL.
LOS_ERRNO_TSK_PRIOR_ERROR  Incorrect task priority.
LOS_ERRNO_TSK_STKSZ_TOO_LARGE  The task stack size is too large.
LOS_ERRNO_TSK_STKSZ_TOO_SMALL  The task stack size is too small.
LOS_ERRNO_TSK_TCB_UNAVAILABLE  No free task control block is available.
LOS_ERRNO_TSK_NO_MEMORY  Insufficient memory for task creation.
LOS_OK  The task is successfully created.
Dependency:
  • los_task.h: the header file that contains the API declaration.
  • los_config.h: the header file that contains system configuration items.
参见:
LOS_TaskDelete
自从:
Huawei LiteOS V100R001C00