Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Donate
Please sign in before you donate.
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
1 Star 0 Fork 46

coder/AliOS-Things

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (69)
Tags (17)
master
rel_1.3.2
rel_1.3.1
rel_1.3.0
rel_2.1.0
rel_2.0.0
rel_1.3.3
rel_1.3.4
aos2.0.0_qcom
update_master_201903201538
update_master_201903192042
update_master_201903192035
developer
update_1.3.3
update_1.3.2
update_1.3.1
update_1.3.0
update_2.0.0
zq_github_demo
zq_aaboard_demo
v2.1.0
v1.3.4
v2.0.0
v1.3.3
master_1.3.x-E-20180808.0800
v1.3.1
v1.3.2
1.3.2
v1.3.0
fea_bone_1.3
v1.2.2
1.2.2_pre
v1.2.1
v1.2.0
v1.1.2
aos1.1.1
aos1.1.0
master
Branches (69)
Tags (17)
master
rel_1.3.2
rel_1.3.1
rel_1.3.0
rel_2.1.0
rel_2.0.0
rel_1.3.3
rel_1.3.4
aos2.0.0_qcom
update_master_201903201538
update_master_201903192042
update_master_201903192035
developer
update_1.3.3
update_1.3.2
update_1.3.1
update_1.3.0
update_2.0.0
zq_github_demo
zq_aaboard_demo
v2.1.0
v1.3.4
v2.0.0
v1.3.3
master_1.3.x-E-20180808.0800
v1.3.1
v1.3.2
1.3.2
v1.3.0
fea_bone_1.3
v1.2.2
1.2.2_pre
v1.2.1
v1.2.0
v1.1.2
aos1.1.1
aos1.1.0
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (69)
Tags (17)
master
rel_1.3.2
rel_1.3.1
rel_1.3.0
rel_2.1.0
rel_2.0.0
rel_1.3.3
rel_1.3.4
aos2.0.0_qcom
update_master_201903201538
update_master_201903192042
update_master_201903192035
developer
update_1.3.3
update_1.3.2
update_1.3.1
update_1.3.0
update_2.0.0
zq_github_demo
zq_aaboard_demo
v2.1.0
v1.3.4
v2.0.0
v1.3.3
master_1.3.x-E-20180808.0800
v1.3.1
v1.3.2
1.3.2
v1.3.0
fea_bone_1.3
v1.2.2
1.2.2_pre
v1.2.1
v1.2.0
v1.1.2
aos1.1.1
aos1.1.0
AliOS-Things
/
kernel
/
debug
/
debug_cpuusage.c
AliOS-Things
/
kernel
/
debug
/
debug_cpuusage.c
debug_cpuusage.c 4.40 KB
Copy Edit Raw Blame History
wuqi.hz authored 2019年01月07日 17:02 +08:00 . BugID:18583575:Integration of kernel statics macros
/*
* Copyright (C) 2015-2018 Alibaba Group Holding Limited
*/
#include "debug_api.h"
#if (RHINO_CONFIG_SYS_STATS > 0)
typedef struct {
char task_name[32];
uint32_t task_cpu_usage;
} task_cpuusage_info;
static uint32_t task_cpu_usage_period = 0;
void debug_task_cpu_usage_stats(void)
{
klist_t *taskhead = &g_kobj_list.task_head;
klist_t *taskend = taskhead;
klist_t *tmp;
ktask_t *task;
static lr_timer_t stats_start = 0;
lr_timer_t stats_end;
CPSR_ALLOC();
RHINO_CPU_INTRPT_DISABLE();
for (tmp = taskhead->next; tmp != taskend; tmp = tmp->next) {
task = krhino_list_entry(tmp, ktask_t, task_stats_item);
task->task_exec_time = task->task_time_total_run -
task->task_time_total_run_prev;
task->task_time_total_run_prev = task->task_time_total_run;
}
RHINO_CPU_INTRPT_ENABLE();
stats_end = (lr_timer_t)LR_COUNT_GET();
task_cpu_usage_period = stats_end - stats_start;
stats_start = stats_end;
}
void debug_total_cpu_usage_show(void)
{
uint32_t i;
klist_t *taskhead = &g_kobj_list.task_head;
klist_t *taskend = taskhead;
klist_t *tmp;
ktask_t *task;
const char *task_name;
lr_timer_t task_cpu_usage;
uint32_t total_cpu_usage[RHINO_CONFIG_CPU_NUM];
uint32_t tasknum = 0;
task_cpuusage_info *taskinfo;
task_cpuusage_info *taskinfoeach;
printf("-----------------------\n");
#if (RHINO_CONFIG_CPU_NUM > 1)
for (i = 0; i < RHINO_CONFIG_CPU_NUM; i++) {
total_cpu_usage[i] = debug_total_cpu_usage_get(i);
printf("CPU usage :%3d.%02d%% \n", (int)total_cpu_usage[i]/100,
(int)total_cpu_usage[i]%100);
}
#else
total_cpu_usage[0] = debug_total_cpu_usage_get(0);
printf("CPU usage :%3d.%02d%% \n", (int)total_cpu_usage[0] / 100,
(int)total_cpu_usage[0] % 100);
#endif
printf("-----------------------\n");
printf("Name %%CPU\n");
printf("-----------------------\n");
krhino_sched_disable();
for (tmp = taskhead->next; tmp != taskend; tmp = tmp->next) {
tasknum ++;
}
taskinfo = krhino_mm_alloc(tasknum * sizeof(task_cpuusage_info));
if (taskinfo == NULL) {
krhino_sched_enable();
}
memset(taskinfo, 0, tasknum * sizeof(task_cpuusage_info));
taskinfoeach = taskinfo;
for (tmp = taskhead->next; tmp != taskend; tmp = tmp->next) {
task = krhino_list_entry(tmp, ktask_t, task_stats_item);
if (task->task_name != NULL) {
task_name = task->task_name;
} else {
task_name = "anonym";
}
taskinfoeach->task_cpu_usage = debug_task_cpu_usage_get(task);
strncpy(taskinfoeach->task_name, task_name, sizeof(taskinfoeach->task_name) - 1);
taskinfoeach++;
}
krhino_sched_enable();
for (i = 0; i < tasknum; i++) {
taskinfoeach = taskinfo + i;
task_name = taskinfoeach->task_name;
task_cpu_usage = taskinfoeach->task_cpu_usage;
printf("%-19s%3d.%02d\n", task_name, (int)task_cpu_usage / 100,
(int)task_cpu_usage % 100);
}
krhino_mm_free(taskinfo);
printf("-----------------------\n");
}
/* one in ten thousand */
uint32_t debug_task_cpu_usage_get(ktask_t *task)
{
uint32_t task_cpu_usage = 0;
if (task_cpu_usage_period == 0) {
return 0;
}
task_cpu_usage = (uint64_t)(task->task_exec_time) * 10000 / task_cpu_usage_period;
return task_cpu_usage;
}
/* one in ten thousand */
uint32_t debug_total_cpu_usage_get(uint32_t cpuid)
{
uint32_t total_cpu_usage = 0;
total_cpu_usage = 10000 - debug_task_cpu_usage_get(&g_idle_task[cpuid]);
return total_cpu_usage;
}
#if (DEBUG_CONFIG_CPU_USAGE_PERIOD > 0)
static ktimer_t cpu_usage_timer;
static void cpu_usage_timer_handler(void *timer, void *args)
{
debug_task_cpu_usage_stats();
}
kstat_t debug_task_cpu_usage_init()
{
kstat_t ret = RHINO_SUCCESS;
sys_time_t cpu_usage_period = krhino_ms_to_ticks(DEBUG_CONFIG_CPU_USAGE_PERIOD);
if (cpu_usage_period == 0) {
return RHINO_INV_PARAM;
}
ret = krhino_timer_create(&cpu_usage_timer, "cpu_usage_timer",
cpu_usage_timer_handler, 1, cpu_usage_period, NULL, 1);
if (ret != RHINO_SUCCESS) {
return ret;
}
return ret;
}
#endif
#endif /* (RHINO_CONFIG_SYS_STATS > 0) */
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

AliOS Things AliOS家族旗下面向IoT领域的轻量级物联网嵌入式操作系统AliOS Things将致力于搭建云端一体化IoT基础设施,具备极致性能、极简开发、云端一体
No labels
Apache-2.0
Use Apache-2.0
Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/mc-coder/AliOS-Things.git
git@gitee.com:mc-coder/AliOS-Things.git
mc-coder
AliOS-Things
AliOS-Things
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /