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

结构体

struct  tagCpupInfo
 

宏定义

#define LOS_ERRNO_CPUP_NO_MEMORY   LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x00)
 
#define LOS_ERRNO_CPUP_TASK_PTR_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x01)
 
#define LOS_ERRNO_CPUP_NO_INIT   LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x02)
 
#define LOS_ERRNO_CPUP_MAXNUM_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x03)
 
#define LOS_ERRNO_CPUP_THREAD_NO_CREATED   LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x04)
 
#define LOS_ERRNO_CPUP_TSK_ID_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x05)
 

类型定义

typedef struct tagCpupInfo CPUP_INFO_S
 

枚举

enum  CpupMode { CPUP_LAST_MULIT_RECORD = 0 , CPUP_LAST_ONE_RECORD = 1 , CPUP_ALL_TIME = 0xffff }
 

函数

UINT32 LOS_HistorySysCpuUsage (UINT32 mode)
 Obtain the historical CPU usage.
 
UINT32 LOS_HistoryTaskCpuUsage (UINT32 taskId, UINT32 mode)
 Obtain the historical CPU usage of a specified task.
 
UINT32 LOS_AllCpuUsage (UINT16 maxNum, CPUP_INFO_S *cpupInfo, UINT32 mode, UINT16 flag)
 Obtain the CPU usage of tasks and hardware interrupts.
 
void LOS_CpupReset (void)
 Reset the data of CPU usage.
 
void LOS_CpupStop (void)
 Stop LiteOS CPUP module.
 
void LOS_CpupStart (void)
 Start LiteOS CPUP module.
 

详细描述

宏定义说明

◆ LOS_ERRNO_CPUP_MAXNUM_INVALID

#define LOS_ERRNO_CPUP_MAXNUM_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x03)

CPU usage error code: The number of threads is invalid.

Value: 0x02001e03.

Solution: Check whether the number of threads is applicable for the current operation.

◆ LOS_ERRNO_CPUP_NO_INIT

#define LOS_ERRNO_CPUP_NO_INIT   LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x02)

CPU usage error code: The CPU usage is not initialized.

Value: 0x02001e02.

Solution: Check whether the CPU usage is initialized.

◆ LOS_ERRNO_CPUP_NO_MEMORY

#define LOS_ERRNO_CPUP_NO_MEMORY   LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x00)

CPU usage error code: The request for memory fails.

Value: 0x02001e00.

Solution: Decrease the maximum number of tasks.

◆ LOS_ERRNO_CPUP_TASK_PTR_NULL

#define LOS_ERRNO_CPUP_TASK_PTR_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x01)

CPU usage error code: The pointer to an input parameter is NULL.

Value: 0x02001e01.

Solution: Check whether the pointer to the input parameter is usable.

◆ LOS_ERRNO_CPUP_THREAD_NO_CREATED

#define LOS_ERRNO_CPUP_THREAD_NO_CREATED   LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x04)

CPU usage error code: The target thread is not created.

Value: 0x02001e04.

Solution: Check whether the target thread is created.

◆ LOS_ERRNO_CPUP_TSK_ID_INVALID

#define LOS_ERRNO_CPUP_TSK_ID_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x05)

CPU usage error code: The target task ID is invalid.

Value: 0x02001e05.

Solution: Check whether the target task ID is applicable for the current operation.

类型定义说明

◆ CPUP_INFO_S

typedef struct tagCpupInfo CPUP_INFO_S

The structure of the CPU usage information of all tasks.

枚举类型说明

◆ CpupMode

enum CpupMode

The time period which the CPU usage collects in.

枚举值
CPUP_LAST_MULIT_RECORD 

Display CPU usage in the last multi sample record, the value is 0.

CPUP_LAST_ONE_RECORD 

Display CPU usage in the last one sample record, the value is 1.

CPUP_ALL_TIME 

Display CPU usage from system startup to now, the value is 0xffff.

函数说明

◆ LOS_AllCpuUsage()

UINT32 LOS_AllCpuUsage ( UINT16  maxNum,
CPUP_INFO_S cpupInfo,
UINT32  mode,
UINT16  flag 
)
extern

Obtain the CPU usage of tasks and hardware interrupts.

Description:
This API is used to obtain the CPU usage of specified number of tasks or hardware interrupts. The first parameter maxNum means the maximum number of tasks or hardware interrupts. And the last parameter flag determines to obtain the CPU usage of tasks or hardware interrupts.
注意
  • This API can be called only the CPU usage has been initialized. Otherwise, the obtainment of the CPU usage will be failed.
  • The input parameter pointer (cpupInfo) must not be NULL, and the maximum number (maxNum) must be usable. Otherwise, the obtainment of the CPU usage will be failed.
  • The input parameter pointer (cpupInfo) point to the structure array whose size should be greater than (maxNum * sizeof(CPUP_INFO_S)).
参数
maxNum[IN] Type UINT16. The Maximum number of tasks or hardware interrupts to be obtained.
cpupInfo[OUT] Type CPUP_INFO_S*. The pointer used to save the CPU usage information.
mode[IN] Type UINT32. Task mode. The parameter value 0 indicates that the CPU usage in the last ten seconds will be obtained, and the parameter value 1 indicates that the CPU usage in the former one second will be obtained. Other values indicate that the CPU usage in all time will be obtained.
flag[IN] Type UINT16. The parameter value 0 indicates that the API only obtains hardware interrupt CPU usage. Other values indicate that the API only obtains the task CPU usage.
返回值
LOS_ERRNO_CPUP_NO_INITThe CPU usage is not initialized.
LOS_ERRNO_CPUP_TASK_PTR_NULLThe input parameter pointer is NULL.
LOS_ERRNO_CPUP_MAXNUM_INVALIDThe maximum number of tasks or hardware interrupts is invalid.
LOS_OKThe CPU usage is successfully obtained.
Dependency:
  • los_cpup.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_CpupReset()

void LOS_CpupReset ( void  )
extern

Reset the data of CPU usage.

Description:
This API is used to reset the CPU usage. It will clear the historical CPU usage. If this API is called, the CPU usage in all time will become the time period from the API calling to now.
注意
None.
参数
None.
返回值
None.
Dependency:
  • los_cpup.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_CpupStart()

void LOS_CpupStart ( void  )
extern

Start LiteOS CPUP module.

Description:
This API is used to start the CPUP module. It will firstly clear the historical CPU usage data to zero, and start periodical software timer to record. If this API is called, the previouly recorded CPU usage data will be ignored and recalculate from then on.
注意
  • When CPUP is already running, the API does not work.
  • API will work when the macro LOSCFG_CPUP_START_STOP is ON.
参数
None.
返回值
None.
Dependency:
  • los_cpup.h: the header file that contains the API declaration.
参见
LOS_CpupStop | LOS_CpupReset

◆ LOS_CpupStop()

void LOS_CpupStop ( void  )
extern

Stop LiteOS CPUP module.

Description:
This API is used to stop the CPUP module. It just only stops the recording periodical software timer, instead of clearing cpup record data. From then on, no more cpup usage information will be recorded.
注意
  • When CPUP is already stopped, the API does not work.
  • API will work when the macro LOSCFG_CPUP_START_STOP is ON.
参数
None.
返回值
None.
Dependency:
  • los_cpup.h: the header file that contains the API declaration.
参见
LOS_CpupStart | LOS_CpupReset

◆ LOS_HistorySysCpuUsage()

UINT32 LOS_HistorySysCpuUsage ( UINT32  mode)
extern

Obtain the historical CPU usage.

Description:
This API is used to obtain the historical CPU usage of the system.
注意
This API can be called only the CPU usage has been initialized. Otherwise, the obtainment of the CPU usage will be failed.
参数
mode[IN] Type UINT32. Task mode. The parameter value 0 indicates that the CPU usage in the last ten seconds will be obtained, and the parameter value 1 indicates that the CPU usage in the former one second will be obtained. Other values indicate that the CPU usage in all time will be obtained.
返回值
LOS_ERRNO_CPUP_NO_INITThe CPU usage is not initialized.
UINT32The historical CPU usage of the system. It is a permillage. And the value range is [0,1000].
Dependency:
  • los_cpup.h: the header file that contains the API declaration.
参见
LOS_HistoryTaskCpuUsage | LOS_AllCpuUsage
自从
Huawei LiteOS V100R001C00

◆ LOS_HistoryTaskCpuUsage()

UINT32 LOS_HistoryTaskCpuUsage ( UINT32  taskId,
UINT32  mode 
)
extern

Obtain the historical CPU usage of a specified task.

Description:
This API is used to obtain the historical CPU usage of a task specified by a passed-in task ID.
注意
  • This API can be called only the CPU usage has been initialized. Otherwise, the obtainment of the CPU usage will be failed.
  • The passed-in task ID must be valid and the task specified by the task ID must has been created. Otherwise, the obtainment of the CPU usage will be failed.
参数
taskId[IN] Type UINT32. Task ID.
mode[IN] Type UINT32. Task mode. The parameter value 0 indicates that the CPU usage in the last ten seconds will be obtained, and the parameter value 1 indicates that the CPU usage in the former one second will be obtained. Other values indicate that the CPU usage in all time will be obtained.
返回值
LOS_ERRNO_CPUP_NO_INITThe CPU usage has not been initialized.
LOS_ERRNO_CPUP_TSK_ID_INVALIDThe passed-in task ID is invalid.
LOS_ERRNO_CPUP_THREAD_NO_CREATEDThe task specified by the task ID has not been created.
UINT32The historical CPU usage of a specified task. It is a permillage. And the value range is [0,1000].
Dependency:
  • los_cpup.h: the header file that contains the API declaration.
参见
LOS_HistorySysCpuUsage
自从
Huawei LiteOS V100R001C00