Date: Tue, 08 Mar 2005 14:40:04 +0000 From: Pete French <petefrench@ticketswitch.com> To: stable@FreeBSD.ORG Subject: Just a sanity check before I sumbit a buig report Message-ID: <E1D8fsS-000KoN-Gj@dilbert.firstcallgroup.co.uk>
next in thread | raw e-mail | index | archive | help
The man page for getrusage says that the frequency of the statistics clock is given by sysconf(_SC_CLK_TCK). The source code to /usr/bin/time uses a function 'getstathz' to get the frequency of the statistics clock which is does using sysctl and KERN_CLOCKRATE On my system the first returns 100Hz and the second 128Hz!!! Now, is this: 1) A bug in /usr/bin/time 2) A bug in sysconf(_SC_CLK_TCK) 3) A bug in the manpage for getrusage 4) A bug in the kernel and the values should not be different 5) A bug in my understanding! Note that although option '4' is unlikely, if I run the test a.out file on other FreeBSD systems I get 128 for both values, which is even odder! -pcf. Test code (will probably give 128 for both on your system) #include <stdio.h> #include <unistd.h> #include <err.h> #include <sys/types.h> #include <sys/time.h> #include <sys/sysctl.h> static int getstathz() { struct clockinfo clockrate; int mib[2]; size_t size; mib[0] = CTL_KERN; mib[1] = KERN_CLOCKRATE; size = sizeof clockrate; if (sysctl(mib, 2, &clockrate, &size, NULL, 0) == -1) err(1, "sysctl kern.clockrate"); return clockrate.stathz; } int main() { printf("get stat hz = %d\n", getstathz()); printf("sysconf clock tick = %ld\n", sysconf(_SC_CLK_TCK)); return 0; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1D8fsS-000KoN-Gj>