LiteOS API  5.0.0
 全部 数据结构 文件 函数 变量 类型定义 枚举 枚举值 宏定义
Task

数据结构

宏定义

类型定义

函数


宏定义文档

Task error code: The task fails to be activated.

Value: 0x03000219.

Solution: Perform task switching after creating an idle task.

Task error code: The task is already suspended.

Value: 0x02000208.

Solution: Suspend the task after it is resumed.

Task error code: Too many task configuration items.

Value: 0x0200021a

Solution: This error code is not in use temporarily.

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

Value: 0x0200021b

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

Value: 0x0200021e

Task error code: The cpu affinity mask is incorrect.

Value: 0x03000223.

Solution: Please set the correct cpu affinity mask.

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

Value: 0x0300020d.

Solution: Perform this operation after exiting from the interrupt.

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

Value: 0x0200020e.

Solution: Perform this operation after unlocking the task.

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

Value: 0x0300020b.

Solution: Unlock the task.

Task error code: The task entrance is NULL.

Value: 0x02000204.

Solution: Define the task entrance function.

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

Value: 0x02000217

Solution: This error code is not in use temporarily.

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.

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

Value: 0x02000212.

Solution: This error code is not in use temporarily.

Task error code: Invalid task ID.

Value: 0x02000207.

Solution: Check the task ID.

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.

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

Value: 0x02000225.

Solution: Expand LOSCFG_BASE_IPC_SEM_LIMIT.

Task error code: The task message is nonzero.

Value: 0x0200020c.

Solution: This error code is not in use temporarily.

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

Value: 0x0200021d

Task error code: The task name is NULL.

Value: 0x02000205.

Solution: Set the task name.

Task error code: Insufficient memory for task creation.

Value: 0x03000200.

Solution: Allocate bigger memory partition to task creation.

Task error code: The task is not created.

Value: 0x0200020a.

Solution: Create the task.

Task error code: The task is not suspended.

Value: 0x02000209.

Solution: Suspend the task.

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.

Task error code: Incorrect task priority.

Value: 0x02000203.

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

Task error code: Null parameter.

Value: 0x02000201.

Solution: Check the parameter.

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

Value: 0x0200021f

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

Value: 0x02000218

Solution: This error code is not in use temporarily.

Task error code: The task stack is not aligned.

Value: 0x02000202.

Solution: Align the task stack.

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

Value: 0x02000220.

Solution: shrink the task stack size parameter.

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

Value: 0x02000206.

Solution: Expand the task stack.

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

Value: 0x03000215.

Solution: Suspend the task after unlocking the task.

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

Value: 0x02000221.

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

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

Value: 0x02000211.

Solution: Increase the number of task control blocks.

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.

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

Value: 0x0200020f.

Solution: Check the task.

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

Value: 0x02000210.

Solution: Increase the number of tasks.

#define LOS_TASK_MIN_STACK_SIZE   (ALIGN(LOSCFG_TASK_MIN_STACK_SIZE, LOSCFG_STACK_POINT_ALIGN_SIZE))

Minimum stack size.

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

#define LOS_TASK_NAMELEN   32

Task name length

#define LOS_TASK_STATUS_DETACHED   0x0100U

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


类型定义文档

typedef VOID*(* TSK_ENTRY_FUNC)(UINTPTR param1, UINTPTR param2, UINTPTR param3, UINTPTR param4)

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
typedef struct tagTskInfo TSK_INFO_S

Task information structure.

Define the structure of the parameters used for task creation.

Information of specified parameters passed in during task creation.

typedef VOID(* TSKSWITCHHOOK)(VOID)

Define the type of the task switching hook function.

Description:
This API is used to define the type of the task switching hook function.
注意:
The function type is defined only when #LOSCFG_BASE_CORE_TSK_MONITOR is set to YES.
参数:
None.
返回值:
None.
Dependency:
  • los_task.h: the header file that contains the API declaration.
自从:
Huawei LiteOS V100R001C00

函数文档

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

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

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
UINT32 LOS_TaskCpuAffiSet ( UINT32  taskId,
UINT16  usCpuAffiMask 
)

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_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
UINT32 LOS_TaskCreate ( UINT32 taskId,
TSK_INIT_PARAM_S initParam 
)

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.
参数:
taskId[OUT] Type UINT32 * Task ID.
initParam[IN] Type TSK_INIT_PARAM_S * Parameter for task creation.
返回值:
LOS_ERRNO_TSK_ID_INVALIDInvalid Task ID, param taskId is NULL.
LOS_ERRNO_TSK_PTR_NULLParam initParam is NULL.
LOS_ERRNO_TSK_NAME_EMPTYThe task name is NULL.
LOS_ERRNO_TSK_ENTRY_NULLThe task entrance is NULL.
LOS_ERRNO_TSK_PRIOR_ERRORIncorrect task priority.
LOS_ERRNO_TSK_STKSZ_TOO_LARGEThe task stack size is too large.
LOS_ERRNO_TSK_STKSZ_TOO_SMALLThe task stack size is too small.
LOS_ERRNO_TSK_TCB_UNAVAILABLENo free task control block is available.
LOS_ERRNO_TSK_NO_MEMORYInsufficient memory for task creation.
LOS_OKThe 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 | LOS_TaskCreateOnly
自从:
Huawei LiteOS V100R001C00
UINT32 LOS_TaskCreateOnly ( UINT32 taskId,
TSK_INIT_PARAM_S initParam 
)

Create a task and suspend.

Description:
This API is used to create a task and suspend it. This task will not be added to the queue of ready tasks before resume it.
注意:
  • 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 stack size should be a reasonable value, if the size is too large, may cause memory exhaustion.
  • 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.
参数:
taskId[OUT] Type UINT32 * Task ID.
initParam[IN] Type TSK_INIT_PARAM_S * Parameter for task creation.
返回值:
LOS_ERRNO_TSK_ID_INVALIDInvalid Task ID, param taskId is NULL.
LOS_ERRNO_TSK_PTR_NULLParam initParam is NULL.
LOS_ERRNO_TSK_NAME_EMPTYThe task name is NULL.
LOS_ERRNO_TSK_ENTRY_NULLThe task entrance is NULL.
LOS_ERRNO_TSK_PRIOR_ERRORIncorrect task priority.
LOS_ERRNO_TSK_STKSZ_TOO_LARGEThe task stack size is too large.
LOS_ERRNO_TSK_STKSZ_TOO_SMALLThe task stack size is too small.
LOS_ERRNO_TSK_TCB_UNAVAILABLENo free task control block is available.
LOS_ERRNO_TSK_NO_MEMORYInsufficient memory for task creation.
LOS_OKThe 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 | LOS_TaskCreate
自从:
Huawei LiteOS V100R001C00
UINT32 LOS_TaskCreateOnlyStatic ( UINT32 taskId,
TSK_INIT_PARAM_S initParam,
VOID topStack 
)

Create a task with User defines stack space and suspend .

Description:
This API is used to create a task and suspend it. This task will not be added to the queue of ready tasks before resume it. User should define a static stack memory and assign to stack pointer, the uwStackSize in taskInitParam must fit the stack memory size.
注意:
  • 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 stack size should be a reasonable value, if the size is too large, may cause memory exhaustion.
  • 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.
  • If user mode is enabled, user should input user stack pointer and size, the size must fit the stack pointer, uwStackSize remain as the kernel stack size.
参数:
taskID[OUT] Type UINT32 * Task ID.
taskInitParam[IN] Type TSK_INIT_PARAM_S * Parameter for task creation.
topOfStack[IN] Type VOID* Parameter for task's top of stack address.
返回值:
LOS_ERRNO_TSK_ID_INVALIDInvalid Task ID, param puwTaskID is NULL.
LOS_ERRNO_TSK_PTR_NULLParam pstInitParam is NULL.
LOS_ERRNO_TSK_NAME_EMPTYThe task name is NULL.
LOS_ERRNO_TSK_ENTRY_NULLThe task entrance is NULL.
LOS_ERRNO_TSK_PRIOR_ERRORIncorrect task priority.
LOS_ERRNO_TSK_STKSZ_TOO_LARGEThe task stack size is too large.
LOS_ERRNO_TSK_STKSZ_TOO_SMALLThe task stack size is too small.
LOS_ERRNO_TSK_TCB_UNAVAILABLENo free task control block is available.
LOS_ERRNO_TSK_NO_MEMORYInsufficient memory for task creation.
LOS_OKThe 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_TaskCreateStatic | LOS_TaskDeleteStatic
自从:
Huawei LiteOS V200R005C10
UINT32 LOS_TaskCreateStatic ( UINT32 taskId,
TSK_INIT_PARAM_S initParam,
VOID topStack 
)

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. User should define a static stack memory and assign to stack pointer, the uwStackSize in taskInitParam must fit the stack memory size. 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.
  • If user mode is enabled, user should input user stack pointer and size, the size must fit the stack pointer, uwStackSize remain as the kernel stack size.
  • If LOSCFG_STATIC_ALLOC_MEM is enabled, user should define a static stack memory and assign to stack pointer, the uwStackSize must fit the stack memory size.
参数:
taskID[OUT] Type UINT32 * Task ID.
taskInitParam[IN] Type TSK_INIT_PARAM_S * Parameter for task creation.
topOfStack[IN] Type VOID * Parameter for task's top of stack address.
返回值:
LOS_ERRNO_TSK_ID_INVALIDInvalid Task ID, param puwTaskID is NULL.
LOS_ERRNO_TSK_PTR_NULLParam pstInitParam is NULL.
LOS_ERRNO_TSK_NAME_EMPTYThe task name is NULL.
LOS_ERRNO_TSK_ENTRY_NULLThe task entrance is NULL.
LOS_ERRNO_TSK_PRIOR_ERRORIncorrect task priority.
LOS_ERRNO_TSK_STKSZ_TOO_LARGEThe task stack size is too large.
LOS_ERRNO_TSK_STKSZ_TOO_SMALLThe task stack size is too small.
LOS_ERRNO_TSK_TCB_UNAVAILABLENo free task control block is available.
LOS_ERRNO_TSK_NO_MEMORYInsufficient memory for task creation.
LOS_OKThe 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_TaskCreateOnlyStatic | LOS_TaskDeleteStatic
自从:
Huawei LiteOS V200R005C10

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

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 shchduled.
参数:
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_OKThe task is successfully deleted.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见:
LOS_TaskCreate | LOS_TaskCreateOnly
自从:
Huawei LiteOS V100R001C00
UINT32 LOS_TaskInfoGet ( UINT32  taskId,
TSK_INFO_S taskInfo 
)

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

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.
参数:
None.
返回值:
None.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见:
LOS_TaskUnlock
自从:
Huawei LiteOS V100R001C00

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
UINT32 LOS_TaskPriSet ( UINT32  taskId,
UINT16  taskPrio 
)

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.
参数:
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_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

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

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_OKThe task is successfully resumed.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见:
LOS_TaskSuspend
自从:
Huawei LiteOS V100R001C00

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_OKThe task is successfully suspended.
Dependency:
  • los_task.h: the header file that contains the API declaration.
参见:
LOS_TaskResume
自从:
Huawei LiteOS V100R001C00

User task switching hook function.

Description:
This API is a user task switching hook register function.
注意:
The function is used only when #LOSCFG_BASE_CORE_TSK_MONITOR is set to YES.
参数:
hook[IN] Type TSKSWITCHHOOK. The user defined hook for task switch.
返回值:
None.
Dependency:
  • los_task.h: the header file that contains the API declaration.
自从:
Huawei LiteOS V200R005C10

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. One is added to the number of task scheduling locks if the task scheduling is locked. 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

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