|
|
/* ----------------------------------------------------------------------------
|
|
|
* Copyright (c) Huawei Technologies Co., Ltd. 2013-2020. All rights reserved.
|
|
|
* Description: Cpup HeadFile
|
|
|
* Author: Huawei LiteOS Team
|
|
|
* Create: 2013-01-01
|
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
|
* are permitted provided that the following conditions are met:
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
|
* conditions and the following disclaimer.
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
|
|
* provided with the distribution.
|
|
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
|
|
* to endorse or promote products derived from this software without specific prior written
|
|
|
* permission.
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
* --------------------------------------------------------------------------- */
|
|
|
|
|
|
#ifndef _LOS_CPUP_PRI_H
|
|
|
#define _LOS_CPUP_PRI_H //防止多次包含同一个头文件//
|
|
|
|
|
|
#include "los_cpup.h" //可能包含了一些与CPU使用率//
|
|
|
#include "los_task_pri.h" //统计相关的公共声明和定义//
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
#if __cplusplus
|
|
|
extern "C" {
|
|
|
#endif /* __cplusplus */
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
#define OS_CPUP_HISTORY_RECORD_NUM 11 //定义历史记录的数量为11//
|
|
|
#define LOS_CPUP_PRECISION 1000 //定义CPU使用率的精度为1000//
|
|
|
#define LOS_CPUP_PRECISION_MULT (LOS_CPUP_PRECISION / 100) //可能用于计算CPU使用率//
|
|
|
|
|
|
typedef struct {
|
|
|
UINT32 id; /* Task ID */
|
|
|
UINT16 status; /* Task status */
|
|
|
UINT64 allTime; /* Total running time */
|
|
|
UINT64 startTime; /* Time before a task is invoked */
|
|
|
UINT64 historyTime[OS_CPUP_HISTORY_RECORD_NUM + 1]; /* Historical running time, the last one saves zero */
|
|
|
} OsCpupCB;
|
|
|
|
|
|
extern OsCpupCB *OsCpupCBGet(UINT32 index); //根据索引获取 `OsCpupCB` 结构体指针//
|
|
|
extern UINT32 OsCpupInit(VOID); //CPU使用率统计模块的初始化函数//
|
|
|
extern VOID OsCpupSetCycle(UINT64 startCycles); //设置CPU周期计数//
|
|
|
extern UINT64 OsCpupGetCycle(VOID); //获取CPU周期计数//
|
|
|
extern VOID OsTaskCycleStart(VOID); //任务运行周期的起始//
|
|
|
extern VOID OsTaskCycleEnd(VOID); //任务运行周期的结束//
|
|
|
extern VOID OsTaskCycleEndStart(const LosTaskCB *newTask); //更新任务运行周期,并开始新的任务周期//
|
|
|
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
|
|
VOID OsCpupIrqStart(VOID); //在前一条条件定义下,用于处理//
|
|
|
VOID OsCpupIrqEnd(UINT32); //中断的CPU使用率统计函数//
|
|
|
#endif
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
#if __cplusplus
|
|
|
}
|
|
|
#endif /* __cplusplus */
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
#endif /* _LOS_CPUP_PRI_H */
|
|
|
|
|
|
/*这段代码定义了一些用于CPU使用率统计的数据结构和函数声明,
|
|
|
用于在操作系统中实现对任务和中断的CPU利用率进行监控和统计。*/ |