convert jiffies to seconds

后端 未结 4 576
悲&欢浪女
悲&欢浪女 2021-01-04 18:28

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 an

4条回答
  •  抹茶落季
    2021-01-04 19:19

    To clarify the math behind MarkR's answer:

    sysconf(_SC_CLK_TCK) will get you jiffies per second. Divide jiffies by the number you get from sysconf(_SC_CLK_TCK) to get the total number of seconds.

          jiffies                      jiffies              seconds
    --------------------    =     -----------------    =    -------    =    seconds
    sysconf(_SC_CLK_TCK)          (jiffies/second)             1
    

提交回复
热议问题