我们怎样才能发现系统处于空闲模式? [英] how can we find out system is in idle mode?
本文介绍了我们怎样才能发现系统处于空闲模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿,我需要找出CPU何时处于空闲模式。我会检索CPU活动大约10分钟,然后计算使用情况。首先,我无法用百分比衡量用量,其次,我不确定它是否可以在多核CPU上工作。
谢谢
Hey, I need to find out when a CPU is in Idle mode. I sould retrieve the CPU activities for about 10 minutes and then calculate the usage. First, I couldn't measure the usage in percent and second, I'm not sure whether it's going to work on a multi core CPU or not.
Thanks
推荐答案
您没有提到您正在运行的平台。在Windows上我会尝试使用
You didn't mention the platform you are running on. On Windows I would try to use
BOOL GetSystemTimes(
LPFILETIME lpIdleTime,
LPFILETIME lpKernelTime,
LPFILETIME lpUserTime
);
并定期拨打电话,每10秒钟说一次。从系统启动以来,您从此调用中获得的值是累积的。因此,你必须做一些算术来计算过去10分钟内平均的CPU负载。
在使用GetSystemTimes获取CPU使用率 [ ^ ]。
查看此链接
如何使用C#让系统处于活动状态,空闲状态,睡眠状态,休眠状态? [ ^ ]
这篇关于我们怎样才能发现系统处于空闲模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文