Re: HZ from userspace

From: Ray Lee
Date: Wed Aug 06 2008 - 18:20:51 EST


On Wed, Aug 6, 2008 at 3:16 PM, Ray Lee <ray-lk@xxxxxxxxxxxxx> wrote:
> On Wed, Aug 6, 2008 at 3:07 PM, Piotr JaroszyÅski
> <p.jaroszynski@xxxxxxxxx> wrote:
>>>> I want to be able to convert starttime from /proc/#/stat to absolute
>>>> time and it seems that I need HZ to do that as it is measured in
>>>> jiffies. How can I get HZ? I have seen some discussion about this but
>>>> haven't found a definite answer. procps is using some hacks do it and
>>>> I would prefer to avoid them.
>>>> I only need a solution for modern kernels, say 2.6.20+ if that matters.
>>>
>>> `man sysconf`, in particular you want sysconf(_SC_CLK_TCK).
>>
>> manpage says it's obsolete and i read in some discussion that it only
>> returns the default and not the real HZ used.
>
> I believe the claim that it's out of date is out of date. manpages
> 3.0.1 has an update to this, according to a message I saw on this list
> a month or so ago.
>
> Regardless, the fields you're reading should all be showing USER_HZ
> which is fixed at 100 per second regardless of the underlying kernel
> HZ parameter.
>
> Try it.
>

Here's the latest proc(5) man page from June 25, 2008. Look for
_SC_CLK_TCK about a third of the way down.

http://www.kernel.org/doc/man-pages/online/pages/man5/proc.5.html
èº{.nÇ+‰·Ÿ®‰­†+%ŠËlzwm…ébëæìr¸›zX§»®w¥Š{ayºÊÚë,j­¢f£¢·hš‹àz¹®w¥¢¸ ¢·¦j:+v‰¨ŠwèjØm¶Ÿÿ¾«‘êçzZ+ƒùšŽŠÝj"ú!¶iO•æ¬z·švØ^¶m§ÿðà nÆàþY&—