WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
Task
Task 的协作图:

结构体

struct  tagTskInitParam
 
struct  tagTskInfo
 

宏定义

#define LOS_TASK_PRIORITY_HIGHEST   0
 
#define LOS_TASK_PRIORITY_LOWEST   31
 
#define LOS_ERRNO_TSK_NO_MEMORY   LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x00)
 
#define LOS_ERRNO_TSK_PTR_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x01)
 
#define LOS_ERRNO_TSK_STKSZ_NOT_ALIGN   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x02)
 
#define LOS_ERRNO_TSK_PRIOR_ERROR   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x03)
 
#define LOS_ERRNO_TSK_ENTRY_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x04)
 
#define LOS_ERRNO_TSK_NAME_EMPTY   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x05)
 
#define LOS_ERRNO_TSK_STKSZ_TOO_SMALL   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x06)
 
#define LOS_ERRNO_TSK_ID_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x07)
 
#define LOS_ERRNO_TSK_ALREADY_SUSPENDED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x08)
 
#define LOS_ERRNO_TSK_NOT_SUSPENDED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x09)
 
#define LOS_ERRNO_TSK_NOT_CREATED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0a)
 
#define LOS_ERRNO_TSK_DELETE_LOCKED   LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x0b)
 
#define LOS_ERRNO_TSK_MSG_NONZERO   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0c)
 
#define LOS_ERRNO_TSK_DELAY_IN_INT   LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x0d)
 
#define LOS_ERRNO_TSK_DELAY_IN_LOCK   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0e)
 
#define LOS_ERRNO_TSK_YIELD_IN_LOCK   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0f)
 
#define LOS_ERRNO_TSK_YIELD_NOT_ENOUGH_TASK   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x10)
 
#define LOS_ERRNO_TSK_TCB_UNAVAILABLE   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x11)
 
#define LOS_ERRNO_TSK_HOOK_NOT_MATCH   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x12)
 
#define LOS_ERRNO_TSK_HOOK_IS_FULL   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x13)
 
#define LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x14)
 
#define LOS_ERRNO_TSK_SUSPEND_LOCKED   LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x15)
 
#define LOS_ERRNO_TSK_FREE_STACK_FAILED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x17)
 
#define LOS_ERRNO_TSK_STKAREA_TOO_SMALL   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x18)
 
#define LOS_ERRNO_TSK_ACTIVE_FAILED   LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x19)
 
#define LOS_ERRNO_TSK_CONFIG_TOO_MANY   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1a)
 
#define LOS_ERRNO_TSK_CP_SAVE_AREA_NOT_ALIGN   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1b)
 
#define LOS_ERRNO_TSK_MSG_Q_TOO_MANY   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1d)
 
#define LOS_ERRNO_TSK_CP_SAVE_AREA_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1e)
 
#define LOS_ERRNO_TSK_SELF_DELETE_ERR   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1f)
 
#define LOS_ERRNO_TSK_STKSZ_TOO_LARGE   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x20)
 
#define LOS_ERRNO_TSK_SUSPEND_SWTMR_NOT_ALLOWED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x21)
 
#define LOS_ERRNO_TSK_CPU_AFFINITY_MASK_ERR   LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x23)
 
#define LOS_ERRNO_TSK_YIELD_IN_INT   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x24)
 
#define LOS_ERRNO_TSK_MP_SYNC_RESOURCE   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x25)
 
#define LOS_ERRNO_TSK_MP_SYNC_FAILED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x26)
 
#define LOS_ERRNO_TSK_ALLOC_SECURE_INT   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x27)
 
#define LOS_ERRNO_TSK_SECURE_ALREADY_ALLOC   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x28)
 
#define LOS_ERRNO_TSK_ALLOC_SECURE_FAILED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x29)
 
#define LOS_ERRNO_TSK_FREE_SECURE_FAILED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2a)
 
#define LOS_ERRNO_TSK_NOT_ALLOW_IN_INT   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2b)
 
#define LOS_ERRNO_TSK_SCHED_LOCKED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2c)
 
#define LOS_ERRNO_TSK_ALREADY_JOIN   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2d)
 
#define LOS_ERRNO_TSK_IS_DETACHED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2e)
 
#define LOS_ERRNO_TSK_NOT_JOIN_SELF   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2f)
 
#define LOS_ERRNO_TSK_IS_ZOMBIE   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x30)
 
#define LOS_TASK_MIN_STACK_SIZE   (LOS_Align(KERNEL_TSK_MIN_STACK_SIZE, LOSCFG_STACK_POINT_ALIGN_SIZE))
 
#define LOS_TASK_NAMELEN   32
 

类型定义

typedef void *(* TSK_ENTRY_FUNC) (void *param)
 Define the type of a task entrance function.
 
typedef struct tagTskInitParam TSK_INIT_PARAM_S
 
typedef struct tagTskInfo TSK_INFO_S
 
typedef void(* LOWPOWERIDLEHOOK) (void)
 Define the lowpower framework process function type.
 
typedef void(* IDLEHANDLERHOOK) (void)
 Define the type of idle handler hook function.
 

枚举

enum  TaskAttrBits { LOS_TASK_OS_ALLOC_SECURE = 1 << 0 , LOS_TASK_STATUS_JOINABLE = 1 << 7 , LOS_TASK_STATUS_DETACHED = 1 << 8 }
 

函数

UINT32 LOS_TaskResume (UINT32 taskId)
 Resume a task.
 
UINT32 LOS_TaskSuspend (UINT32 taskId)
 Suspend a task.
 
UINT32 LOS_TaskDelete (UINT32 taskId)
 Delete a task.
 
UINT32 LOS_TaskDelay (UINT32 tick)
 Delay a task.
 
BOOL LOS_TaskIsScheduled (void)
 To check if the current running core is scheduled.
 
void LOS_TaskLock (void)
 Lock the task scheduling.
 
void LOS_TaskUnlock (void)
 Unlock the task scheduling.
 
void LOS_TaskUnlockNoSched (void)
 Unlock the task scheduling and no scheduling is generated.
 
UINT32 LOS_TaskPriSet (UINT32 taskId, UINT16 taskPrio)
 Set a task priority.
 
UINT32 LOS_CurTaskPriSet (UINT16 taskPrio)
 Set the priority of the current running task to a specified priority.
 
UINT32 LOS_TaskYield (void)
 Change the scheduling sequence of tasks with the same priority.
 
UINT16 LOS_TaskPriGet (UINT32 taskId)
 Obtain a task priority.
 
UINT32 LOS_CurTaskIDGet (void)
 Obtain current running task ID.
 
UINT32 LOS_TaskInfoGet (UINT32 taskId, TSK_INFO_S *taskInfo)
 Obtain a task information structure.
 
UINT32 LOS_TaskCpuAffiSet (UINT32 taskId, UINT16 usCpuAffiMask)
 Set the affinity mask of the task scheduling cpu.
 
UINT16 LOS_TaskCpuAffiGet (UINT32 taskId)
 Get the affinity mask of the task scheduling cpu.
 
void LOS_TaskResRecycle (void)
 Recycle task stack resource.
 
void LOS_LowpowerHookReg (LOWPOWERIDLEHOOK hook)
 Register a hook to enter lowpower framework process.
 
void LOS_IdleHandlerHookReg (IDLEHANDLERHOOK hook)
 Register the hook function for idle task.
 
UINT32 LOS_TaskDetach (UINT32 taskId)
 Modify the task attributes to detach.
 
UINT32 LOS_TaskJoin (UINT32 taskId, UINTPTR *retval)
 Join with a terminated thread.
 

详细描述

宏定义说明

◆ LOS_ERRNO_TSK_ACTIVE_FAILED

#define LOS_ERRNO_TSK_ACTIVE_FAILED   LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x19)

Task error code: The task fails to be activated.

Value: 0x03000219.

Solution: Perform task switching after creating an idle task.

弃用:
This error code is obsolete since LiteOS 5.0.0.

◆ LOS_ERRNO_TSK_ALLOC_SECURE_FAILED

#define LOS_ERRNO_TSK_ALLOC_SECURE_FAILED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x29)

Task error code: Failed to apply for the security task stack.

Value: 0x02000229.

Solution: Check the usage scenario and the size of the secure memory pool.

◆ LOS_ERRNO_TSK_ALLOC_SECURE_INT

#define LOS_ERRNO_TSK_ALLOC_SECURE_INT   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x27)

Task error code: Apply for the security task stack in interrupt.

Value: 0x02000227.

Solution: Don't apply for the security task stack in interrupt.

◆ LOS_ERRNO_TSK_ALREADY_JOIN

#define LOS_ERRNO_TSK_ALREADY_JOIN   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2d)

Task error code: A task cannot be waiting for multiple tasks.

Value: 0x0200022d.

Solution: Check whether other tasks are waiting for this task.

◆ LOS_ERRNO_TSK_ALREADY_SUSPENDED

#define LOS_ERRNO_TSK_ALREADY_SUSPENDED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x08)

Task error code: The task is already suspended.

Value: 0x02000208.

Solution: Suspend the task after it is resumed.

◆ LOS_ERRNO_TSK_CONFIG_TOO_MANY

#define LOS_ERRNO_TSK_CONFIG_TOO_MANY   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1a)

Task error code: Too many task configuration items.

Value: 0x0200021a

Solution: This error code is not in use temporarily.

弃用:
This error code is obsolete since LiteOS 5.0.0.

◆ LOS_ERRNO_TSK_CP_SAVE_AREA_NOT_ALIGN

#define LOS_ERRNO_TSK_CP_SAVE_AREA_NOT_ALIGN   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1b)

Task error code: This error code is not in use temporarily.

Value: 0x0200021b

弃用:
This error code is obsolete since LiteOS 5.0.0.

◆ LOS_ERRNO_TSK_CP_SAVE_AREA_NULL

#define LOS_ERRNO_TSK_CP_SAVE_AREA_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1e)

Task error code: This error code is not in use temporarily.

Value: 0x0200021e

弃用:
This error code is obsolete since LiteOS 5.0.0.

◆ LOS_ERRNO_TSK_CPU_AFFINITY_MASK_ERR

#define LOS_ERRNO_TSK_CPU_AFFINITY_MASK_ERR   LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x23)

Task error code: The cpu affinity mask is incorrect.

Value: 0x03000223.

Solution: Please set the correct cpu affinity mask.

◆ LOS_ERRNO_TSK_DELAY_IN_INT

#define LOS_ERRNO_TSK_DELAY_IN_INT   LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x0d)

Task error code: The task delay occurs during an interrupt.

Value: 0x0300020d.

Solution: Perform this operation after exiting from the interrupt.

◆ LOS_ERRNO_TSK_DELAY_IN_LOCK

#define LOS_ERRNO_TSK_DELAY_IN_LOCK   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0e)

Task error code: The task delay occurs when the task is locked.

Value: 0x0200020e.

Solution: Perform this operation after unlocking the task.

◆ LOS_ERRNO_TSK_DELETE_LOCKED

#define LOS_ERRNO_TSK_DELETE_LOCKED   LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x0b)

Task error code: The task is locked when it is being deleted.

Value: 0x0300020b.

Solution: Unlock the task.

◆ LOS_ERRNO_TSK_ENTRY_NULL

#define LOS_ERRNO_TSK_ENTRY_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x04)

Task error code: The task entrance is NULL.

Value: 0x02000204.

Solution: Define the task entrance function.

◆ LOS_ERRNO_TSK_FREE_SECURE_FAILED

#define LOS_ERRNO_TSK_FREE_SECURE_FAILED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2a)

Task error code: Failed to free the security task stack.

Value: 0x0200022a.

Solution: Check the usage scenario and parameter.

◆ LOS_ERRNO_TSK_FREE_STACK_FAILED

#define LOS_ERRNO_TSK_FREE_STACK_FAILED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x17)

Task error code: The task stack fails to be freed.

Value: 0x02000217

Solution: This error code is not in use temporarily.

弃用:
This error code is obsolete since LiteOS 5.0.0.

◆ LOS_ERRNO_TSK_HOOK_IS_FULL

#define LOS_ERRNO_TSK_HOOK_IS_FULL   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x13)

Task error code: The number of task hook functions exceeds the permitted upper limit.

Value: 0x02000213.

Solution: This error code is not in use temporarily.

弃用:
This error code is obsolete since LiteOS 5.0.0.

◆ LOS_ERRNO_TSK_HOOK_NOT_MATCH

#define LOS_ERRNO_TSK_HOOK_NOT_MATCH   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x12)

Task error code: The task hook function is not matchable.

Value: 0x02000212.

Solution: This error code is not in use temporarily.

弃用:
This error code is obsolete since LiteOS 5.0.0.

◆ LOS_ERRNO_TSK_ID_INVALID

#define LOS_ERRNO_TSK_ID_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x07)

Task error code: Invalid task ID.

Value: 0x02000207.

Solution: Check the task ID.

◆ LOS_ERRNO_TSK_IS_DETACHED

#define LOS_ERRNO_TSK_IS_DETACHED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2e)

Task error code: This task is detached attr.

Value: 0x0200022e.

Solution: Check the task properties and whether it is waiting for other tasks to finish.

◆ LOS_ERRNO_TSK_IS_ZOMBIE

#define LOS_ERRNO_TSK_IS_ZOMBIE   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x30)

Task error code: An "zombie" task cannot be operated.

Value: 0x02000230.

Solution: Check whether a Joinable task exists. If so, call LOS_TaskJoin to reclaim resources.

◆ LOS_ERRNO_TSK_MP_SYNC_FAILED

#define LOS_ERRNO_TSK_MP_SYNC_FAILED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x26)

Task error code: Task sync failed on operating running task across cores.

Value: 0x02000226.

Solution: Check task delete can be handled in user's scenario.

◆ LOS_ERRNO_TSK_MP_SYNC_RESOURCE

#define LOS_ERRNO_TSK_MP_SYNC_RESOURCE   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x25)

Task error code: Task sync resource (semaphore) allocated failed.

Value: 0x02000225.

Solution: Expand LOSCFG_BASE_IPC_SEM_LIMIT.

◆ LOS_ERRNO_TSK_MSG_NONZERO

#define LOS_ERRNO_TSK_MSG_NONZERO   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0c)

Task error code: The task message is nonzero.

Value: 0x0200020c.

Solution: This error code is not in use temporarily.

弃用:
This error code is obsolete since LiteOS 5.0.0.

◆ LOS_ERRNO_TSK_MSG_Q_TOO_MANY

#define LOS_ERRNO_TSK_MSG_Q_TOO_MANY   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1d)

Task error code: This error code is not in use temporarily.

Value: 0x0200021d

弃用:
This error code is obsolete since LiteOS 5.0.0.

◆ LOS_ERRNO_TSK_NAME_EMPTY

#define LOS_ERRNO_TSK_NAME_EMPTY   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x05)

Task error code: The task name is NULL.

Value: 0x02000205.

Solution: Set the task name.

◆ LOS_ERRNO_TSK_NO_MEMORY

#define LOS_ERRNO_TSK_NO_MEMORY   LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x00)

Task error code: Insufficient memory for task creation.

Value: 0x03000200.

Solution: Allocate bigger memory partition to task creation.

◆ LOS_ERRNO_TSK_NOT_ALLOW_IN_INT

#define LOS_ERRNO_TSK_NOT_ALLOW_IN_INT   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2b)

Task error code: This task operation is not allowed to be performed in an interrupt.

Value: 0x0200022b.

Solution: Check whether the interface is used in interrupts.

◆ LOS_ERRNO_TSK_NOT_CREATED

#define LOS_ERRNO_TSK_NOT_CREATED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0a)

Task error code: The task is not created.

Value: 0x0200020a.

Solution: Create the task.

◆ LOS_ERRNO_TSK_NOT_JOIN_SELF

#define LOS_ERRNO_TSK_NOT_JOIN_SELF   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2f)

Task error code: Tasks can't join himself.

Value: 0x0200022f.

Solution: Check whether the task ID is the current running task.

◆ LOS_ERRNO_TSK_NOT_SUSPENDED

#define LOS_ERRNO_TSK_NOT_SUSPENDED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x09)

Task error code: The task is not suspended.

Value: 0x02000209.

Solution: Suspend the task.

◆ LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK

#define LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x14)

Task error code: The operation is performed on the system-level task. old usage: The operation is performed on the idle task (LOS_ERRNO_TSK_OPERATE_IDLE)

Value: 0x02000214.

Solution: Check the task ID and do not operate the system-level task.

◆ LOS_ERRNO_TSK_PRIOR_ERROR

#define LOS_ERRNO_TSK_PRIOR_ERROR   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x03)

Task error code: Incorrect task priority.

Value: 0x02000203.

Solution: Re-configure the task priority by referring to the priority range.

◆ LOS_ERRNO_TSK_PTR_NULL

#define LOS_ERRNO_TSK_PTR_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x01)

Task error code: Null parameter.

Value: 0x02000201.

Solution: Check the parameter.

◆ LOS_ERRNO_TSK_SCHED_LOCKED

#define LOS_ERRNO_TSK_SCHED_LOCKED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2c)

Task error code: Locked scheduling does not allow tasks to be blocked.

Value: 0x0200022c.

Solution: Check for faulty lock scheduling logic.

◆ LOS_ERRNO_TSK_SECURE_ALREADY_ALLOC

#define LOS_ERRNO_TSK_SECURE_ALREADY_ALLOC   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x28)

Task error code: The security task stack is already allocated.

Value: 0x02000228.

Solution: Don't reapply.

◆ LOS_ERRNO_TSK_SELF_DELETE_ERR

#define LOS_ERRNO_TSK_SELF_DELETE_ERR   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1f)

Task error code: This error code is not in use temporarily.

Value: 0x0200021f

弃用:
This error code is obsolete since LiteOS 5.0.0.

◆ LOS_ERRNO_TSK_STKAREA_TOO_SMALL

#define LOS_ERRNO_TSK_STKAREA_TOO_SMALL   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x18)

Task error code: The task stack area is too small.

Value: 0x02000218

Solution: This error code is not in use temporarily.

弃用:
This error code is obsolete since LiteOS 5.0.0.

◆ LOS_ERRNO_TSK_STKSZ_NOT_ALIGN

#define LOS_ERRNO_TSK_STKSZ_NOT_ALIGN   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x02)

Task error code: The task stack is not aligned.

Value: 0x02000202.

Solution: Align the task stack.

◆ LOS_ERRNO_TSK_STKSZ_TOO_LARGE

#define LOS_ERRNO_TSK_STKSZ_TOO_LARGE   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x20)

Task error code: The task stack size is too large.

Value: 0x02000220.

Solution: shrink the task stack size parameter.

◆ LOS_ERRNO_TSK_STKSZ_TOO_SMALL

#define LOS_ERRNO_TSK_STKSZ_TOO_SMALL   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x06)

Task error code: The task stack size is too small.

Value: 0x02000206.

Solution: Expand the task stack.

◆ LOS_ERRNO_TSK_SUSPEND_LOCKED

#define LOS_ERRNO_TSK_SUSPEND_LOCKED   LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x15)

Task error code: The task that is being suspended is locked.

Value: 0x03000215.

Solution: Suspend the task after unlocking the task.

◆ LOS_ERRNO_TSK_SUSPEND_SWTMR_NOT_ALLOWED

#define LOS_ERRNO_TSK_SUSPEND_SWTMR_NOT_ALLOWED   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x21)

Task error code: Suspending software timer task is not allowed.

Value: 0x02000221.

Solution: Check the task ID and do not suspend software timer task.

弃用:
This error code is obsolete since LiteOS 5.0.0.

◆ LOS_ERRNO_TSK_TCB_UNAVAILABLE

#define LOS_ERRNO_TSK_TCB_UNAVAILABLE   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x11)

Task error code: No free task control block is available.

Value: 0x02000211.

Solution: Increase the number of task control blocks.

◆ LOS_ERRNO_TSK_YIELD_IN_INT

#define LOS_ERRNO_TSK_YIELD_IN_INT   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x24)

Task error code: Task yield in interrupt is not permited, which will result in an unexpected result.

Value: 0x02000224.

Solution: Don't call LOS_TaskYield in Interrupt.

◆ LOS_ERRNO_TSK_YIELD_IN_LOCK

#define LOS_ERRNO_TSK_YIELD_IN_LOCK   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0f)

Task error code: The task yield occurs when the task is locked.

Value: 0x0200020f.

Solution: Check the task.

◆ LOS_ERRNO_TSK_YIELD_NOT_ENOUGH_TASK

#define LOS_ERRNO_TSK_YIELD_NOT_ENOUGH_TASK   LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x10)

Task error code: Only one task or no task is available for scheduling.

Value: 0x02000210.

Solution: Increase the number of tasks.

◆ LOS_TASK_MIN_STACK_SIZE

#define LOS_TASK_MIN_STACK_SIZE   (LOS_Align(KERNEL_TSK_MIN_STACK_SIZE, LOSCFG_STACK_POINT_ALIGN_SIZE))

Minimum stack size.

LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE bytes, configured in menuconfig. LOS_TASK_MIN_STACK_SIZE bytes, aligned on a boundary of LOSCFG_STACK_POINT_ALIGN_SIZE.

◆ LOS_TASK_NAMELEN

#define LOS_TASK_NAMELEN   32

Task name length

◆ LOS_TASK_PRIORITY_HIGHEST

#define LOS_TASK_PRIORITY_HIGHEST   0

Highest task priority

◆ LOS_TASK_PRIORITY_LOWEST

#define LOS_TASK_PRIORITY_LOWEST   31

Lowest task priority

类型定义说明

◆ IDLEHANDLERHOOK

typedef void(* IDLEHANDLERHOOK) (void)

Define the type of idle handler hook function.

Description:
This API is used to define the type of idle handler hook function.
注意
None.
参数
None.
返回值
None.
Dependency:
  • los_task.h: the header file that contains the API declaration.
自从
Huawei LiteOS V200R005C20

◆ LOWPOWERIDLEHOOK

typedef void(* LOWPOWERIDLEHOOK) (void)

Define the lowpower framework process function type.

Description:
This API is used to define the lowpower framework entry function type.
注意
None.
参数
None.
返回值
None.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见
None.
自从
Huawei LiteOS V200R005C10

◆ TSK_ENTRY_FUNC

typedef void *(* TSK_ENTRY_FUNC) (void *param)

Define the type of a task entrance function.

Description:
This API is used to define the type of a task entrance function and call it after a task is created and triggered.
注意
If LOSCFG_OBSOLETE_API is not defined, one parameter which its type is VOID * will be instead of these four parameters of the API.
参数
param1[IN] Type UINTPTR The first parameter passed to the task handling function.
param2[IN] Type UINTPTR The second parameter passed to the task handling function.
param3[IN] Type UINTPTR The third parameter passed to the task handling function.
param4[IN] Type UINTPTR The fourth parameter passed to the task handling function.
返回值
None.
Dependency:
  • los_task.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ TSK_INFO_S

typedef struct tagTskInfo TSK_INFO_S

Task information structure.

◆ TSK_INIT_PARAM_S

Define the structure of the parameters used for task creation.

Information of specified parameters passed in during task creation.

枚举类型说明

◆ TaskAttrBits

Set the bits of task parameters during task creation.

枚举值
LOS_TASK_OS_ALLOC_SECURE 

Flag that indicates the the security task stack is allocated by the OS. The setting is valid only when the trust feature of ARMv8-M is enabled.

LOS_TASK_STATUS_JOINABLE 

Flag that indicates the task or task control block status. This is means the task is in the non-auto-deleted state. In this state, the task will not be deleted automatically after the task is done.

LOS_TASK_STATUS_DETACHED 

Flag that indicates the task or task control block status. This is means the task is in the auto-deleted state. In this state, the task will be deleted automatically after the task is done.

函数说明

◆ LOS_CurTaskIDGet()

UINT32 LOS_CurTaskIDGet ( void  )
extern

Obtain current running task ID.

Description:
This API is used to obtain the ID of current running task.
注意
This interface should not be called before system initialized.
返回值
LOS_ERRNO_TSK_ID_INVALIDCan not get current running task.
UINT32Task ID.
Dependency:
  • los_task.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_CurTaskPriSet()

UINT32 LOS_CurTaskPriSet ( UINT16  taskPrio)
extern

Set the priority of the current running task to a specified priority.

Description:
This API is used to set the priority of the current running task to a specified priority.
注意
  • Changing the priority of the current running task probably causes task scheduling.
  • Using the interface to change the priority of software timer task and idle task is not allowed.
  • Using the interface in the interrupt is not allowed.
参数
taskPrio[IN] Type UINT16 Task priority.
返回值
LOS_ERRNO_TSK_PRIOR_ERRORIncorrect task priority.Re-configure the task priority.
LOS_ERRNO_TSK_ID_INVALIDThe current task ID is invalid.
LOS_ERRNO_TSK_OPERATE_SYSTEM_TASKThe current task is a system-level task, like idle or swtmr task. This is not allowed.
LOS_ERRNO_TSK_NOT_CREATEDThe task is not created.
LOS_OKThe priority of the current running task is successfully set to a specified priority.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见
LOS_TaskPriSet | LOS_TaskPriGet
自从
Huawei LiteOS V100R001C00

◆ LOS_IdleHandlerHookReg()

void LOS_IdleHandlerHookReg ( IDLEHANDLERHOOK  hook)
extern

Register the hook function for idle task.

Description:
This API is used to register a hook function called when system idle.
注意
The hook will be called when system idle.
参数
None.
返回值
None.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见
None.
自从
Huawei LiteOS V200R005C20

◆ LOS_LowpowerHookReg()

void LOS_LowpowerHookReg ( LOWPOWERIDLEHOOK  hook)
extern

Register a hook to enter lowpower framework process.

Description:
This API is used to register lowpower framework entry function.
注意
None.
参数
hook[IN] The lowpower framework hook.
返回值
None.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见
None.
自从
Huawei LiteOS V200R005C10

◆ LOS_TaskCpuAffiGet()

UINT16 LOS_TaskCpuAffiGet ( UINT32  taskId)
extern

Get the affinity mask of the task scheduling cpu.

Description:
This API is used to get the affinity mask of the task scheduling cpu.
注意
None.
参数
taskId[IN] Type UINT32 Task ID. The task id value is obtained from task creation.
返回值
0Fail to obtain the cpu affinity mask.
UINT16The scheduling cpu mask. The low to high bit of the mask corresponds to the cpu number.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见
LOS_TaskCpuAffiSet
自从
Huawei LiteOS V200R003C00

◆ LOS_TaskCpuAffiSet()

UINT32 LOS_TaskCpuAffiSet ( UINT32  taskId,
UINT16  usCpuAffiMask 
)
extern

Set the affinity mask of the task scheduling cpu.

Description:
This API is used to set the affinity mask of the task scheduling cpu.
注意
If any low LOSCFG_KERNEL_CORE_NUM bit of the mask is not set or the system task is set, an error is reported.
参数
taskId[IN] Type UINT32 Task ID. The task id value is obtained from task creation.
usCpuAffiMask[IN] Type UINT16 The scheduling cpu mask.The low to high bit of the mask corresponds to the cpu number, the high bit that exceeding the CPU number is ignored.
返回值
LOS_ERRNO_TSK_ID_INVALIDInvalid task ID.
LOS_ERRNO_TSK_NOT_CREATEDThe task is not created.
LOS_ERRNO_TSK_CPU_AFFINITY_MASK_ERRThe task cpu affinity mask is incorrect.
LOS_ERRNO_TSK_OPERATE_SYSTEM_TASKThe task is system task.
LOS_ERRNO_TSK_IS_ZOMBIEThe task is in a "zombie" state.
LOS_OKThe task cpu affinity mask is successfully set.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见
LOS_TaskCpuAffiGet
自从
Huawei LiteOS V200R003C00

◆ LOS_TaskDelay()

UINT32 LOS_TaskDelay ( UINT32  tick)
extern

Delay a task.

Description:
This API is used to delay the execution of the current task. The task is able to be scheduled after it is delayed for a specified number of Ticks.
注意
  • The task fails to be delayed if it is being delayed during interrupt processing or it is locked.
  • If 0 is passed in and the task scheduling is not locked, execute the next task in the queue of tasks with the same priority of the current task. If no ready task with the priority of the current task is available, the task scheduling will not occur, and the current task continues to be executed.
  • Using the interface before system initialized is not allowed.
  • DO NOT call this API in software timer callback.
参数
tick[IN] Type UINT32 Number of Ticks for which the task is delayed.
返回值
LOS_ERRNO_TSK_DELAY_IN_INTThe task delay occurs during an interrupt.
LOS_ERRNO_TSK_OPERATE_SYSTEM_TASKThe current task is a system-level task, like idle or swtmr task. This is not allowed.
LOS_ERRNO_TSK_DELAY_IN_LOCKThe task delay occurs when the task scheduling is locked.
LOS_ERRNO_TSK_ID_INVALIDInvalid Task ID
LOS_ERRNO_TSK_YIELD_NOT_ENOUGH_TASKNo tasks with the same priority is available for scheduling.
LOS_OKThe task is successfully delayed.
Dependency:
  • los_task.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_TaskDelete()

UINT32 LOS_TaskDelete ( UINT32  taskId)
extern

Delete a task.

Description:
This API is used to delete a specified task and release the resources for its task stack and task control block.
注意
  • The idle task and swtmr task cannot be deleted.
  • If delete current task maybe cause unexpected error.
  • If a task get a mutex is deleted or automatically deleted before release this mutex, other tasks pended this mutex maybe never be scheduled.
参数
taskId[IN] Type UINT32 Task ID. The task id value is obtained from task creation.
返回值
LOS_ERRNO_TSK_ID_INVALIDInvalid Task ID
LOS_ERRNO_TSK_OPERATE_SYSTEM_TASKCheck the task ID and do not operate the system-level task, like idle or swtmr task.
LOS_ERRNO_TSK_NOT_CREATEDThe task is not created.
LOS_ERRNO_TSK_DELETE_LOCKEDThe task being deleted is current task and task scheduling is locked.
LOS_ERRNO_TSK_FREE_SECURE_FAILEDFailed to free the security task stack.
LOS_OKThe task is successfully deleted.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见
LOS_TaskCreate | LOS_TaskCreateOnly
自从
Huawei LiteOS V100R001C00

◆ LOS_TaskDetach()

UINT32 LOS_TaskDetach ( UINT32  taskId)
extern

Modify the task attributes to detach.

Description:
This API is used to modify the attribute of the specified task to detach.
注意
None.
参数
taskId[IN] Type UINT32 Task ID. The task id value is obtained from task creation.
返回值
LOS_ERRNO_TSK_ID_INVALIDInvalid Task ID.
LOS_ERRNO_TSK_NOT_ALLOW_IN_INTNot allowed in interrupt context.
LOS_ERRNO_TSK_NOT_CREATEDThe task is not created.
LOS_ERRNO_TSK_IS_DETACHEDThe task is already a detach task.
LOS_ERRNO_TSK_ALREADY_JOINA task is waiting for this task.
LOS_ERRNO_TSK_OPERATE_SYSTEM_TASKThis task is a system task.
LOS_OKModify the task attributes to detach is successfully.
Dependency:
  • los_task.h: the header file that contains the API declaration.

◆ LOS_TaskInfoGet()

UINT32 LOS_TaskInfoGet ( UINT32  taskId,
TSK_INFO_S taskInfo 
)
extern

Obtain a task information structure.

Description:
This API is used to obtain a task information structure.
注意
One parameter of this interface is a pointer, it should be a correct value, otherwise, the system may be abnormal.
参数
taskId[IN] Type UINT32 Task ID. The task id value is obtained from task creation.
taskInfo[OUT] Type TSK_INFO_S* Pointer to the task information structure to be obtained.
返回值
LOS_ERRNO_TSK_PTR_NULLNull parameter.
LOS_ERRNO_TSK_ID_INVALIDInvalid task ID.
LOS_ERRNO_TSK_NOT_CREATEDThe task is not created.
LOS_OKThe task information structure is successfully obtained.
Dependency:
  • los_task.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_TaskIsScheduled()

BOOL LOS_TaskIsScheduled ( void  )
extern

To check if the current running core is scheduled.

Description:
This API is used to check if the current running core is scheduled.
注意
  • If the core is scheduled, some API can be used, like LOS_TaskDelay, which maybe cause task switching.
参数
None.
返回值
TrueThe current running core is scheduled.
FalseThe current running core is start-up, not int multi-task environment.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见
LOS_TaskUnlock LOS_TaskLock
自从
Huawei LiteOS 206.1.0

◆ LOS_TaskJoin()

UINT32 LOS_TaskJoin ( UINT32  taskId,
UINTPTR retval 
)
extern

Join with a terminated thread.

Description:
This API is used to wait for the subtask to finish and reclaim the resource.
注意
None.
参数
taskId[IN] Type UINT32 Task ID. The task id value is obtained from task creation.
retval[IN] Value returned when the task is complete.
返回值
LOS_ERRNO_TSK_ID_INVALIDInvalid Task ID.
LOS_ERRNO_TSK_NOT_ALLOW_IN_INTNot allowed in interrupt context.
LOS_ERRNO_TSK_SCHED_LOCKEDThis task cannot be invoked when locked scheduled.
LOS_ERRNO_TSK_NOT_JOIN_SELFTasks can't join himself.
LOS_ERRNO_TSK_OPERATE_SYSTEM_TASKThis task is a system task.
LOS_ERRNO_TSK_NOT_CREATEDThe task is not created.
LOS_ERRNO_TSK_IS_DETACHEDCannot join a detach task.
LOS_ERRNO_TSK_ALREADY_JOINA task is waiting for this task.
LOS_OKModify the task attributes to detach is successfully.
Dependency:
  • los_task.h: the header file that contains the API declaration.

◆ LOS_TaskLock()

void LOS_TaskLock ( void  )
extern

Lock the task scheduling.

Description:
This API is used to lock the task scheduling. Task switching will not occur if the task scheduling is locked.
注意
  • If the task scheduling is locked, but interrupts are not disabled, tasks are still able to be interrupted.
  • One is added to the number of task scheduling locks if this API is called. The number of locks is decreased by one if the task scheduling is unlocked. Therefore, this API should be used together with LOS_TaskUnlock or LOS_TaskUnlockNoSched.
参数
None.
返回值
None.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见
LOS_TaskUnlock
自从
Huawei LiteOS V100R001C00

◆ LOS_TaskPriGet()

UINT16 LOS_TaskPriGet ( UINT32  taskId)
extern

Obtain a task priority.

Description:
This API is used to obtain the priority of a specified task.
注意
None.
参数
taskId[IN] Type UINT32 Task ID. The task id value is obtained from task creation.
返回值
OS_INVALIDFails to obtain the task priority.
UINT16The task priority.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见
LOS_TaskPriSet
自从
Huawei LiteOS V100R001C00

◆ LOS_TaskPriSet()

UINT32 LOS_TaskPriSet ( UINT32  taskId,
UINT16  taskPrio 
)
extern

Set a task priority.

Description:
This API is used to set the priority of a specified task.
注意
  • If the set priority is higher than the priority of the current running task, task scheduling probably occurs.
  • Changing the priority of the current running task also probably causes task scheduling.
  • Using the interface to change the priority of software timer task and idle task is not allowed.
  • Using the interface in the interrupt is not allowed.
  • Before the system starts, it is not allowed to call, otherwise the interface behavior is undefined.
参数
taskId[IN] Type UINT32 Task ID. The task id value is obtained from task creation.
taskPrio[IN] Type UINT16 Task priority.
返回值
LOS_ERRNO_TSK_PRIOR_ERRORIncorrect task priority.Re-configure the task priority
LOS_ERRNO_TSK_ID_INVALIDInvalid Task ID
LOS_ERRNO_TSK_OPERATE_SYSTEM_TASKCheck the task ID and do not operate the system-level task, like idle or swtmr task.
LOS_ERRNO_TSK_NOT_CREATEDThe task is not created.
LOS_ERRNO_TSK_IS_ZOMBIEThe task is in a "zombie" state.
LOS_OKThe priority of the current running task is successfully set to a specified priority.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见
LOS_TaskPriGet
自从
Huawei LiteOS V100R001C00

◆ LOS_TaskResRecycle()

void LOS_TaskResRecycle ( void  )
extern

Recycle task stack resource.

Description:
This API is used to recycle task stack resource.
注意
None.
参数
None.
返回值
None.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见
None.
自从
Huawei LiteOS V200R003C00

◆ LOS_TaskResume()

UINT32 LOS_TaskResume ( UINT32  taskId)
extern

Resume a task.

Description:
This API is used to resume a suspended task.
注意
  • If the task is delayed or blocked, resume the task without adding it to the queue of ready tasks.
  • If the priority of the task resumed after system initialized is higher than the current task and task scheduling is not locked, it is scheduled for running.
参数
taskId[IN] Type UINT32 Task ID. The task id value is obtained from task creation.
返回值
LOS_ERRNO_TSK_ID_INVALIDInvalid Task ID
LOS_ERRNO_TSK_NOT_CREATEDThe task is not created.
LOS_ERRNO_TSK_NOT_SUSPENDEDThe task is not suspended.
LOS_ERRNO_TSK_IS_ZOMBIEThe task is in a "zombie" state.
LOS_OKThe task is successfully resumed.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见
LOS_TaskSuspend
自从
Huawei LiteOS V100R001C00

◆ LOS_TaskSuspend()

UINT32 LOS_TaskSuspend ( UINT32  taskId)
extern

Suspend a task.

Description:
This API is used to suspend a specified task, and the task will be removed from the queue of ready tasks.
注意
  • The task that is running and locked cannot be suspended.
  • The idle task and swtmr task cannot be suspended.
参数
taskId[IN] Type UINT32 Task ID. The task id value is obtained from task creation.
返回值
LOS_ERRNO_TSK_ID_INVALIDInvalid Task ID
LOS_ERRNO_TSK_OPERATE_SYSTEM_TASKCheck the task ID and do not operate the system-level task, like idle or swtmr task.
LOS_ERRNO_TSK_NOT_CREATEDThe task is not created.
LOS_ERRNO_TSK_ALREADY_SUSPENDEDThe task is already suspended.
LOS_ERRNO_TSK_SUSPEND_LOCKEDThe task being suspended is current task and task scheduling is locked.
LOS_ERRNO_TSK_IS_ZOMBIEThe task is in a "zombie" state.
LOS_OKThe task is successfully suspended.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见
LOS_TaskResume
自从
Huawei LiteOS V100R001C00

◆ LOS_TaskUnlock()

void LOS_TaskUnlock ( void  )
extern

Unlock the task scheduling.

Description:
This API is used to unlock the task scheduling. Calling this API will decrease the number of task locks by one. If a task is locked more than once, the task scheduling will be unlocked only when the number of locks becomes zero.
注意
  • The number of locks is decreased by one if this API is called, and the number of locks increases by one only in LOS_TaskLock. Therefore, this API should be used together with LOS_TaskLock.
参数
None.
返回值
None.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见
LOS_TaskLock
自从
Huawei LiteOS V100R001C00

◆ LOS_TaskUnlockNoSched()

void LOS_TaskUnlockNoSched ( void  )
extern

Unlock the task scheduling and no scheduling is generated.

Description:
This API is used to unlock the task scheduling. Calling this API will decrease the number of task locks by one, and then unlocked the task scheduling.
注意
  • The number of locks is decreased by one if this API is called, and the number of locks increases by one only in LOS_TaskLock. Therefore, this API should be used together with LOS_TaskLock.
  • This function is used only by LOS_SpinUnlockNoSched. For details, see the comments of LOS_SpinUnlockNoSched.
参数
None.
返回值
None.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见
LOS_TaskLock
自从
Huawei LiteOS 207.0.0

◆ LOS_TaskYield()

UINT32 LOS_TaskYield ( void  )
extern

Change the scheduling sequence of tasks with the same priority.

Description:
This API is used to move current task in a queue of tasks with the same priority to the tail of the queue of ready tasks.
注意
At least two ready tasks need to be included in the queue of ready tasks with the same priority. If the less than two ready tasks are included in the queue, an error is reported.
参数
None.
返回值
LOS_ERRNO_TSK_YIELD_IN_INTThe task yield occurs during an interrupt.
LOS_ERRNO_TSK_YIELD_IN_LOCKThe task yield occurs when the task is locked.
LOS_ERRNO_TSK_ID_INVALIDThe current task ID is invalid.
LOS_ERRNO_TSK_YIELD_NOT_ENOUGH_TASKNo tasks with the same priority is available for scheduling.
LOS_OKThe scheduling sequence of tasks with same priority is successfully changed.
Dependency:
  • los_task.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00