我有一段用户空间代码解析/ proc/PID/task/TID/stat来获取cpu用法.我可以使用HZ来获取每秒的jiffies,但是这段代码可以移动到具有不同配置值的另一台机器.有没有办法在运行时从用户空间获取HZ的值?
如何使用c语言在ubuntu linux机器上查找进程启动时间。在 linux 中有提供信息的 /proc/[pid]/stat 文件
starttime %lu /*The time in jiffies the process started after system boot*/
和文件 /proc/stat 给出
btime %lu /*measurement of system boot time since Epoch in seconds*/
Run Code Online (Sandbox Code Playgroud)
为了添加这两个值,我如何将前一个值转换为秒,因为它以 jiffies 为单位。