将 jiffies 转换为秒

编程入门 行业动态 更新时间:2024-10-10 08:23:04
本文介绍了将 jiffies 转换为秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一段用户空间代码,它正在解析/proc/PID/task/TID/stat 以获取 cpu 使用情况.我可以使用 HZ 获得每秒 jiffies,但此代码可以移动到另一台具有不同配置值的机器.有没有办法在运行时从用户空间获取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).

更多推荐

将 jiffies 转换为秒

本文发布于:2023-11-28 19:23:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643653.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   jiffies

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!