完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
原子哥,你给的ucos教程中(原子教你玩STM32库函数版本,第53章 ---消息队列、信号量集和软件定时器),计算CPU使用率,获取的值为cpuusage,为什么要除于5? 代码如下:
void tmr1_callback(OS_TMR *ptmr,void *p_arg) { static u16 cpuusage=0; static u8 tcnt=0; POINT_COLOR=BLUE; if(tcnt==5) { LCD_ShowxNum(182,10,cpuusage/5,3,16,0);//CPU使用率 printf("cpuusage=%drn",cpuusage); cpuusage=0; tcnt=0; } cpuusage+=OSCPUUsage; tcnt++; LCD_ShowxNum(182,30,mem_perused(SRAMIN),3,16,0); LCD_ShowxNum(182,50,((OS_Q*)(q_msg->OSEventPtr))->OSQEntries,3,16,0X80);/ } 我查看了OSCPUUsage 的解释为: ********************************************************************************************************* * STATISTICS TASK * * Description: This task is internal to uC/OS-II and is used to compute some statistics about the * multitasking environment. Specifically, OS_TaskStat() computes the CPU usage. * CPU usage is determined by: * * OSIdleCtr * OSCPUUsage = 100 * (1 - ------------) (units are in %) * OSIdleCtrMax * * Arguments : parg this pointer is not used at this time. * * Returns : none * * Notes : 1) This task runs at a priority level higher than the idle task. In fact, it runs at the * next higher priority, OS_TASK_IDLE_PRIO-1. * 2) You can disable this task by setting the configuration #define OS_TASK_STAT_EN to 0. * 3) You MUST have at least a delay of 2/10 seconds to allow for the system to establish the * maximum value for the idle counter. |
|
相关推荐
1个回答
|
|
|
平均值,看下边处理部分
|
|
|
|
|
只有小组成员才能发言,加入小组>>
1018 浏览 1 评论
1849 浏览 0 评论
1830 浏览 1 评论
3254 浏览 5 评论
3581 浏览 9 评论
1021浏览 1评论
1850浏览 1评论
如何知道嵌入式电子控制单元 (ECU) 中的RAM使用情况?
1360浏览 1评论
1852浏览 0评论
1178浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 03:58 , Processed in 0.817606 second(s), Total 74, Slave 54 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2494