初级会员
- 积分
- 99
- 金钱
- 99
- 注册时间
- 2014-7-5
- 在线时间
- 14 小时
|
1金钱
原子哥,你给的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=%d\r\n",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.
|
|