转换成秒 [英] convert jiffies to seconds

查看:110
本文介绍了转换成秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一段用户空间代码,该代码正在解析/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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆