转换成秒 [英] convert jiffies to seconds
问题描述
我有一段用户空间代码,该代码正在解析/proc/PID/task/TID/stat以获取cpu的使用情况.我可以使用HZ来获取每秒的跳动,但是此代码可以移动到另一台具有不同配置值的机器上.有什么方法可以在运行时从用户空间获取HZ的值吗?
I've got a piece of userspace code which is parsing /proc/PID/task/TID/stat to get the cpu usage. I can use HZ to get the jiffies per second but this code could move to another machine which has a different configured value. Is there any way to get the value of HZ from userspace at runtime?
推荐答案
您将其除以从sysconf(_SC_CLK_TCK)获得的数字.
You divide it by the number you get from sysconf(_SC_CLK_TCK).
但是,我认为在Linux下,不管实际的时钟频率是多少,它总是100.它总是以100呈现给用户空间.
However, I think this is probably always 100 under Linux regardless of the actual clock tick, it's always presented to userspace as 100.
请参见man proc(5).
See man proc(5).
这篇关于转换成秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!