Re: times(2) no sys_call ??

David Mosberger-Tang (davidm@azstarnet.com)
Sat, 11 May 1996 12:52:10 -0700


The clock frequency of the Alpha is 1024Hz, that's where the 1024
comes from. The PC uses 100Hz, that's where the 100 comes from. The
"standard"/default value on BSD-derived implementations is 60Hz for
the times() call (which, most of the time, is not related to the clock
tick of the kernel).

The problem is that no matter what value we pick, there is a danger
that CLK_TCK will be wrong (since it's hardcoded, but any given
machine may pick its own clock frequency). It's not a problem so far
since all Alpha platforms I know of use 1024Hz as their clock rate.
I'd be inclined to implement times() in libc using a CLK_TCK of 60
since (a) that's what DEC Unix uses and (b) there is absolutely
nothing in POSIX/X/Open that requires CLK_TCK to be related to the the
kernel's clock tick. But, unfortunately, Linux does provide a times()
system call, so doing so would be confusing and incompatible with
Linux/x86. Now, you might say that using the times() system call is
not a problem since there is sysconf(_SC_CLK_TCK) but Linux does not
provide such system call. In other words, it's implementd in the
library. In fact, glibc currently simply returns the value of
CLK_TCK.

The above shows precisely why I think times() is braindead. Something
like getrusage() returns time in physical units that are meaningful no
matter what machine/kernel/library combination you're running.

Nevertheless, I'll make sure glibc will work correctly provided the
system really has a clock tick that runs at a frequency of HZ (as
defined in /usr/include/asm/param.h).

--david