• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2009-2022 Huawei Technologies Co., Ltd. All rights reserved.
3  *
4  * UniProton is licensed under Mulan PSL v2.
5  * You can use this software according to the terms and conditions of the Mulan PSL v2.
6  * You may obtain a copy of Mulan PSL v2 at:
7  *          http://license.coscl.org.cn/MulanPSL2
8  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
9  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
10  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11  * See the Mulan PSL v2 for more details.
12  * Create: 2009-12-22
13  * Description: cpu占用率模块的内部公共头文件
14  */
15 #ifndef PRT_CPUP_EXTERNAL_H
16 #define PRT_CPUP_EXTERNAL_H
17 
18 #include "prt_cpup.h"
19 
20 /*
21  * 设置cpu占用率的注册信息结构体。
22  */
23 struct TagOsCpupWarnInfo {
24     /* CPU占用率告警阈值 */
25     U32 warn;
26     /* CPU占用率告警恢复阈值 */
27     U32 resume;
28 };
29 
30 /*
31  * 线程级CPU占用率结构体
32  */
33 struct TagCpupThread {
34     /* 运行总时间记录 */
35     U64 allTime;
36     /* 调用前时间记录 */
37     U64 startTime;
38     /* CPU占用率 */
39     U16 usage;
40     /* 保留 */
41     U16 reserve;
42     /* 保留,64位对齐(R8 cacheline)> */
43     U32 reserve2;
44 };
45 
46 #define OS_CPUP_INT_ID 0xffffffff /* 中断线程ID */
47 #define CPUP_USE_RATE 10000 /* CPUP使用比率 10000:万分比  1000:千分比  100:百分比 */
48 
49 typedef void (*CpupWarnFunc)(void);
50 typedef U32(*CpupNowFunc)(void);
51 typedef void (*CpupCoreSleepFunc)(void);
52 
53 extern struct TagOsCpupWarnInfo g_cpupWarnInfo;
54 extern struct TagCpupThread *g_cpup;
55 extern U16 g_sysUsage;
56 
57 extern bool OsCpupInitIsDone(void);
58 extern U32 OsCpupLazyInit(void);
59 
60 /* 核休眠钩子函数 */
61 extern volatile CpupCoreSleepFunc g_cpupCoreSleep;
62 
63 #if defined(OS_OPTION_CPUP)
64 /* CPUP核休眠钩子注册 */
65 #define OS_CPUP_CORE_SLEEP_HOOK_SET(handle) \
66     do {                                    \
67         if (OsCpupInitIsDone()) {           \
68             g_cpupCoreSleep = (handle);     \
69         }                                   \
70     } while (0)
71 #else
72 #define OS_CPUP_CORE_SLEEP_HOOK_SET(handle)
73 #endif
74 
75 #endif /* PRT_CPUP_EXTERNAL_H */
76