finding out the value of HZ from userspace
[various people]
Quoted 9 lines
Quoted 6 lines
This horrible hack of converting all tick values to 100 (from 1000) for export to user space because a large number of user space programs assume that HZ is 100 would NOT be necessary if there was a mechanism whereby user space programs could find out how many ticks there are in a second instead of having to make assumptions.
there is one. Nothing uses it
(sysconf()provides this info)
If you have a recent glibc on a recent kernel, it might. You could also get a -1 or a supposed ABI value that has nothing to do with the kernel currently running. The most reliable way is to first look around on the stack in search of ELF notes, and then fall back to some horribly gross hacks as needed.
Quoted 2 lines
/proc/interrupts"leaks" the value of HZ. On x86, for instance:
( cat/proc/interrupts; sleep 5; cat/proc/interrupts) | grep timer
That doesn't really count. The code could be set to do a dozen interrupts per jiffie tick. Jiffies are what matter.
Quoted 4 lines
Quoted 2 lines
It seem to change from system to system and between 2.4 (100 on i386) to 2.6 (1000 on i386).
And can also be tweaked when compiling, and depends on architecture, and...
Yep. For Linux 2.4.xx and up, ELF notes provide the data. For older systems, you need to compute the ratio of uptime to total jiffies.
Quoted 9 lines
Quoted 6 lines
This horrible hack of converting all tick values to 100 (from 1000) for export to user space because a large number of user space programs assume that HZ is 100 would NOT be necessary if there was a mechanism whereby user space programs could find out how many ticks there are in a second instead of having to make assumptions.
Already exists for a long time -
AT_CLKTCK. glibc has a nice wrapper for it too (sysconf)
AT_CLKTCK is new with the 2.4 kernel. When it is missing or unsupported by an old glibc, the sysconf() call returns a guess instead of an error code. So sysconf() is worthless if you want to support old kernels (Debian!) or old glibc.
Quoted 2 lines
This is not only obscure sysctls, ps and top are also consumers of such jiffies values in /proc
They follow AT_CLKTCK when it is available, not a HZ value from some header file. So you can change HZ quite a bit and these tools won't mind.
Quoted 6 lines
1) Because Linux had long time HZ=100 hardcoded (except on Alphas) and lots of applications probably use that value today (as HZ in their source and not sysconf(...)) - especially since 2.4 (at least most of them) has HZ=100 except for 64bit CPUs).
That is severely broken anyway.
At least with Linux 2.4 kernels, many ports have used a hardware-specific HZ value. All did, really, if you consider user-mode Linux. My table:
10 S/390 (sometimes) 20 user-mode Linux 32 ia64 emulator 64 StrongARM /Shark 100 normal Linux 128 MIPS, ARM 1000 ARM 1024 Alpha, ia64 1200 Alpha
Any app supporting Linux 2.4 with an old glibc or supporting Linux 2.2 will need to do something evil.
Quoted 8 lines
A related issue that's bugged me for a long time is lack of userspace access to the quantity that's called '
freq_scale' in 2.4, where it's (1<<SHIFT_HZ)/HZ for HZ!=100 and 128/128.125 for HZ==100. (I haven't started to reverse-engineer the equivalent value in 2.6, I took a quick look once and concluded things had got a little more hairy.)
Quoted 12 lines
My interest is that I maintain (in spare-time) an NTP application called chrony (http://chrony.sunsite.dk/),
originally written to be good for dial-up, i.e. NTP servers accessible for a short window once or twice a day. This app wants to tune the parameters it passes toadjtimex()to take a best shot at keeping the system clock correct over the potentially 'long' offline period. To do this well, it has to reverse-compensate for thefreq_scalemultiplier that the kernel will apply to the frequency value passed toadjtimex(). Getting the right value for this across different kernels has always been a fragile exercise.
Arrrrgh!!!! I thought I had it bad.
Fortunately this is a fresh new reason to beg Linus for some data. (all previous arguments have been rejected) What would be useful for you?
HZ (-1 for tickless?)USER_HZfreq_scale
some boolean to indicate ppc-like (pure cycle counter) time ???
Quoted 10 lines · Albert Cahalan
Fortunately this is a fresh new reason to beg Linus for some data. (all previous arguments have been rejected) What would be useful for you?
HZ (-1 for tickless?)
USER_HZfreq_scale
some boolean to indicate ppc-like (pure cycle counter) time ???
freq_scale would be a good starting point, I think.
However, there is worse. There is bounds checking on the txc.freq argument to adjtimex(). IIRC the bounds have changed at various points in the kernel history, but at one time the limit was +/- 100ppm. At the time, I had a mobo with a -300ppm clock error. To cope with this, chrony modifies txc.tick to take out the gross error as well as txc.freq to adjust the fine error. Therefore, it needs some idea of how tick and freq inter-relate, and what the valid range of values for tick is. This is another mess. I need to go away and think some more to know info from the kernel side would make the problem easier to code for, though.
Signature · 2 lines
Richard \\\ SH-4/SH-5 Core & Debug Architect Curnow \\\ SuperH (UK) Ltd, Bristol
Quoted 9 lines · Albert Cahalan
Quoted 2 lines
there is one. Nothing uses it
(sysconf()provides this info)If you have a recent glibc on a recent kernel, it might. You could also get a -1 or a supposed ABI value that has nothing to do with the kernel currently running. The most reliable way is to first look around on the stack in search of ELF notes, and then fall back to some horribly gross hacks as needed.
eh sysconf() is the nice way to get to the ELF notes instead of having to grovel yourself.
Quoted 11 lines · Arjan van de Ven
Quoted 9 lines · Albert Cahalan
Quoted 2 lines
there is one. Nothing uses it
(sysconf()provides this info)If you have a recent glibc on a recent kernel, it might. You could also get a -1 or a supposed ABI value that has nothing to do with the kernel currently running. The most reliable way is to first look around on the stack in search of ELF notes, and then fall back to some horribly gross hacks as needed.
Quoted 2 lines
eh
sysconf()is the nice way to get to the ELF notes instead of having to grovel yourself.
Unless there is some hidden feature that lets me specify the ELF note number directly, no way.
The sysconf(_SC_CLK_TCK) call does not return an error code when used on a 2.2.xx i386 kernel. You get an arbitrary value that fails for ARM, Alpha, and any system with modified HZ.
You can't rely on sysconf(_SC_NPROCESSORS_CONF) or sysconf(_SC_NPROCESSORS_ONLN) either. You'll get back a 0 from the SPARC glibc, which really means 0 processors since -1 is the error code.
Whatever the question, "use sysconf" is most likely not the answer.
The man page ought to mention this.
Quoted 18 lines · Albert Cahalan
Quoted 12 lines · Arjan van de Ven
Quoted 9 lines · Albert Cahalan
Quoted 2 lines
there is one. Nothing uses it
(sysconf()provides this info)If you have a recent glibc on a recent kernel, it might. You could also get a -1 or a supposed ABI value that has nothing to do with the kernel currently running. The most reliable way is to first look around on the stack in search of ELF notes, and then fall back to some horribly gross hacks as needed.
Quoted 2 lines
eh
sysconf()is the nice way to get to the ELF notes instead of having to grovel yourself.
Quoted 7 lines
Unless there is some hidden feature that lets me specify the ELF note number directly, no way.
The
sysconf(_SC_CLK_TCK)call does not return an error code when used on a 2.2.xx i386 kernel. You get an arbitrary value that fails for ARM, Alpha, and any system with modified HZ.
As Linux is supposed to be POSIX compliant this is a bug and should be fixed.
Peter
Signature · 4 lines
Dr Peter Williams, Chief Scientist [email protected] Aurema Pty Limited Tel:+61 2 9698 2322 PO Box 305, Strawberry Hills NSW 2012, Australia Fax:+61 2 9699 9174 79 Myrtle Street, Chippendale NSW 2008, Australia http://www.aurema.com
On Sun, 21 Mar 2004 10:58:20 +1100 Peter Williams wrote:
| Albert Cahalan wrote: | > On Sat, 2004-03-20 at 04:56, Arjan van de Ven wrote: | > | >>On Tue, Mar 16, 2004 at 11:14:59AM -0500, Albert Cahalan wrote: | >> | >>>>there is one. Nothing uses it | >>>>(sysconf() provides this info) | >>> | >>>If you have a recent glibc on a recent kernel, it might. | >>>You could also get a -1 or a supposed ABI value that | >>>has nothing to do with the kernel currently running. | >>>The most reliable way is to first look around on the | >>>stack in search of ELF notes, and then fall back to | >>>some horribly gross hacks as needed. | >> | >>eh sysconf() is the nice way to get to the ELF notes | >>instead of having to grovel yourself. | > | > | > Unless there is some hidden feature that lets | > me specify the ELF note number directly, no way. | > | > The sysconf(_SC_CLK_TCK) call does not return an | > error code when used on a 2.2.xx i386 kernel. | > You get an arbitrary value that fails for ARM, | > Alpha, and any system with modified HZ. | | As Linux is supposed to be POSIX compliant this is a bug and should be | fixed.
My understanding (from a few years back) is that Linux is POSIX if/when/where it makes sense, but not necessarily POSIX-just-to-be-POSIX.
--
~Randy
"You can't do anything without having to do something else first." -- Belefant's Law
Quoted 26 lines
| >>>>there is one. Nothing uses it | >>>>(sysconf() provides this info) | >>> | >>>If you have a recent glibc on a recent kernel, it might. | >>>You could also get a -1 or a supposed ABI value that | >>>has nothing to do with the kernel currently running. | >>>The most reliable way is to first look around on the | >>>stack in search of ELF notes, and then fall back to | >>>some horribly gross hacks as needed. | >> | >>eh sysconf() is the nice way to get to the ELF notes | >>instead of having to grovel yourself. | > | > | > Unless there is some hidden feature that lets | > me specify the ELF note number directly, no way. | > | > The sysconf(_SC_CLK_TCK) call does not return an | > error code when used on a 2.2.xx i386 kernel. | > You get an arbitrary value that fails for ARM, | > Alpha, and any system with modified HZ. | | As Linux is supposed to be POSIX compliant this is a bug and should be | fixed.
Quoted 2 lines
My understanding (from a few years back) is that Linux is POSIX if/when/where it makes sense, but not necessarily POSIX-just-to-be-POSIX.
The fixing has been done.
This is not yet helpful for app developers, because old kernels and old libraries are still in use.
If you rely on sysconf(_SC_CLK_TCK) to work, then your software will support:
* all systems with a 2.6.xx kernel
* all systems with a 2.4.xx kernel and recent glibc
* all i386 systems running with the default HZ
That's quite a bit I suppose. Maybe you have no interest in supporting a 1200 HZ Alpha with an old kernel or glibc. Maybe you don't care about somebody running a 2.2.xx kernel with modified HZ.
For the moment, I still care. I won't for long.
Quoted 11 lines · Albert Cahalan
If you rely on
sysconf(_SC_CLK_TCK)to work, then your software will support:* all systems with a 2.6.xx kernel
* all systems with a 2.4.xx kernel and recent glibc
* all i386 systems running with the default HZThat's quite a bit I suppose. Maybe you have no interest in supporting a 1200 HZ Alpha with an old kernel or glibc. Maybe you don't care about somebody running a 2.2.xx kernel with modified HZ.
I'm still unclear. Does sysconf(_SC_CLK_TCK), when it is reliable, return HZ or USER_HZ?
-- Jamie
Quoted 8 lines · Jamie Lokier
Quoted 7 lines · Albert Cahalan
If you rely on
sysconf(_SC_CLK_TCK)to work, then your software will support:* all systems with a 2.6.xx kernel
* all systems with a 2.4.xx kernel and recent glibc
* all i386 systems running with the default HZ
Quoted 7 lines
Quoted 4 lines
That's quite a bit I suppose. Maybe you have no interest in supporting a 1200 HZ Alpha with an old kernel or glibc. Maybe you don't care about somebody running a 2.2.xx kernel with modified HZ.
I'm still unclear. Does
sysconf(_SC_CLK_TCK), when it is reliable, return HZ orUSER_HZ?
USER_HZ; the value all the userspace interfaces are in. HZ doesn't mean nothing, esp when we go to a tickless kernel...
Quoted 1 line · Arjan van de Ven
HZ doesn't mean nothing, esp when we go to a tickless kernel...
As explained several times in this thread, HZ is meaningful because it affects the rounding in select/poll/epoll/setitimer. A few userspace programs with low jitter soft-RT timing requirements need to compensate for that rounding and/or deliberately synchronise themselves with the tick.
Such programs can determine HZ experimentally and lock onto the tick in the manner of a PLL, but it would be nice to simply be able to have the value, to reduce the number of control variables.
When we go to a tickless kernel and offer high-resolution timers to userspace, then it will be irrelevant. Until then, or if the kernel goes tickless but limits the resolution of timers for efficiency, the value of HZ is still relevant.
Not to get irritatingly back to the subject of this thread or anything, but... is the value of HZ reported to userspace anywhere?
Thanks :)
-- Jamie
Quoted 18 lines · Jamie Lokier
Quoted 1 line · Arjan van de Ven
HZ doesn't mean nothing, esp when we go to a tickless kernel...
As explained several times in this thread, HZ is meaningful because it affects the rounding in select/poll/epoll/setitimer. A few userspace programs with low jitter soft-RT timing requirements need to compensate for that rounding and/or deliberately synchronise themselves with the tick.
Such programs can determine HZ experimentally and lock onto the tick in the manner of a PLL, but it would be nice to simply be able to have the value, to reduce the number of control variables.
When we go to a tickless kernel and offer high-resolution timers to userspace, then it will be irrelevant. Until then, or if the kernel goes tickless but limits the resolution of timers for efficiency, the value of HZ is still relevant.
Quoted 5 lines
Not to get irritatingly back to the subject of this thread or anything, but... is the value of HZ reported to userspace anywhere?
Thanks :)
-- Jamie
I may be naive, but what's the matter with:
#include <stdio.h>
#include <sys/param.h> // Required to be here!
int main()
{
printf("HZ=%d\n", HZ);
return 0;
}It works for me.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.24 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.
Quoted 5 lines · Richard B. Johnson
Quoted 2 lines
Not to get irritatingly back to the subject of this thread or anything, but... is the value of HZ reported to userspace anywhere?
I may be naive, but what's the matter with:
Quoted 7 lines
#include <
sys/param.h> // Required to be here!
intmain(){ printf("HZ=%d\n", HZ); return 0; }It works for me.
It gives the wrong answer for HZ on 2.6 kernels. Try it.
The value called "HZ" we are talking about in this thread is the timer interrupt frequency. On 2.6 kernels, on x86, that is 1000. Your program prints 100.
The reason that you are able to use "HZ" from userspace and get the wrong answer is that the macros have different names when used from userspace than from kernelspace.
The value your program reports is what we mean by USER_HZ in this thread. That macro is renamed to HZ when the kernel header <linux/param.h> is included from userspace, for backward source compatibility with some programs.
Your method also perpetuates the problem that USER_HZ is hard-coded as a constant into programs, so cannot ever be changed. Perhaps the header files should redefine "HZ" to call sysconf(_SC_CLK_TCK) nowadays, but presently they don't.
-- Jamie
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 10 lines · Richard B. Johnson
I may be naive, but what's the matter with:
#include <
stdio.h>
#include <sys/param.h> // Required to be here!
intmain(){ printf("HZ=%d\n", HZ); return 0; }It works for me.
What when you compile this tool under a system with, for example 2.4 kern-headers, and switch to a system with a 2.6 kernel and kern-headers? It still reports HZ=100 and that's not true anymore.
- --
Regards Michael Buesch [ http://www.tuxsoft.de.vu ]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFAbIkzFGK1OIvVOP4RArmgAJ0QKFVPLjyYH/OZVox9TLGEGSKHWACcC6FP b++fJyobg5K+FP7Nskx4Djo=
=SckD
-----END PGP SIGNATURE-----
Quoted 31 lines · Richard B. Johnson
Quoted 19 lines · Jamie Lokier
Quoted 1 line · Arjan van de Ven
HZ doesn't mean nothing, esp when we go to a tickless kernel...
As explained several times in this thread, HZ is meaningful because it affects the rounding in select/poll/epoll/setitimer. A few userspace programs with low jitter soft-RT timing requirements need to compensate for that rounding and/or deliberately synchronise themselves with the tick.
Such programs can determine HZ experimentally and lock onto the tick in the manner of a PLL, but it would be nice to simply be able to have the value, to reduce the number of control variables.
When we go to a tickless kernel and offer high-resolution timers to userspace, then it will be irrelevant. Until then, or if the kernel goes tickless but limits the resolution of timers for efficiency, the value of HZ is still relevant.
Quoted 5 lines
Not to get irritatingly back to the subject of this thread or anything, but... is the value of HZ reported to userspace anywhere?
Thanks :)
-- JamieI may be naive, but what's the matter with:
Quoted 8 lines
#include <
stdio.h>
#include <sys/param.h> // Required to be here!
intmain(){ printf("HZ=%d\n", HZ); return 0; }It works for me.
There's no guarantee that the kernel that's running was compiled using that header file which (on my system i.e. RedHat 9) comes as part of the glibc package. It also gets the value indirectly via linux/param.h which in turn gets it via asm/param.h which makes any such program highly non portable. Not to mention that the HZ obtained this way is 100 which is actually not the same as HZ in the 2.6.5-rc3 kernel that I'm running.
Peter
Signature · 4 lines
Dr Peter Williams, Chief Scientist [email protected] Aurema Pty Limited Tel:+61 2 9698 2322 PO Box 305, Strawberry Hills NSW 2012, Australia Fax:+61 2 9699 9174 79 Myrtle Street, Chippendale NSW 2008, Australia http://www.aurema.com
Quoted 11 lines · Jamie Lokier
Quoted 1 line · Arjan van de Ven
HZ doesn't mean nothing, esp when we go to a tickless kernel...
As explained several times in this thread, HZ is meaningful because it affects the rounding in select/poll/epoll/setitimer. A few userspace programs with low jitter soft-RT timing requirements need to compensate for that rounding and/or deliberately synchronise themselves with the tick.
Quoted 8 lines
Such programs can determine HZ experimentally and lock onto the tick in the manner of a PLL, but it would be nice to simply be able to have the value, to reduce the number of control variables.
When we go to a tickless kernel and offer high-resolution timers to userspace, then it will be irrelevant. Until then, or if the kernel goes tickless but limits the resolution of timers for efficiency, the value of HZ is still relevant.
The resolution will always be limited. That's the nature of digital systems. Unlimited resolution would require real "real" numbers and that's not possible. The nearest you get on a digital system is the floating point APPROXIMATION to real numbers.
Quoted 3 lines
Not to get irritatingly back to the subject of this thread or anything, but... is the value of HZ reported to userspace anywhere?
I don't think so. There are those (I'm not one) who insist that to do so would be a bug.
IMHO, as I've said several times, USER_HZ should be changed to be equal to or greater than HZ. In fact, if having USER_HZ greater than HZ would still make it unusable for your purposes, I'd change that opinion to say USER_HZ should be equal to HZ (or, in other words, cease to exist).
Peter
Signature · 4 lines
Dr Peter Williams, Chief Scientist [email protected] Aurema Pty Limited Tel:+61 2 9698 2322 PO Box 305, Strawberry Hills NSW 2012, Australia Fax:+61 2 9699 9174 79 Myrtle Street, Chippendale NSW 2008, Australia http://www.aurema.com
Quoted 9 lines · Peter Williams
Quoted 4 lines
When we go to a tickless kernel and offer high-resolution timers to userspace, then it will be irrelevant. Until then, or if the kernel goes tickless but limits the resolution of timers for efficiency, the value of HZ is still relevant.
The resolution will always be limited. That's the nature of digital systems. Unlimited resolution would require real "real" numbers and that's not possible. The nearest you get on a digital system is the floating point APPROXIMATION to real numbers.
Sure, but HZ will still be irrelevant. There won't be a HZ to report.
Quoted 4 lines
IMHO, as I've said several times,
USER_HZshould be changed to be equal to or greater than HZ. In fact, if havingUSER_HZgreater than HZ would still make it unusable for your purposes, I'd change that opinion to sayUSER_HZshould be equal to HZ (or, in other words, cease to exist).
It's not possible to change USER_HZ. There are too many programs with the number hard-coded into the binary. The best we could do is make the HZ userspace macro non-constant, so it calls sysconf(_SC_CLK_TCK), and wait a few years until practically all programs being used no longer contain a hard-coded constant. Then we could get rid of USER_HZ again.
-- Jamie
Quoted 10 lines · Jamie Lokier
Quoted 6 lines · Peter Williams
Quoted 4 lines
When we go to a tickless kernel and offer high-resolution timers to userspace, then it will be irrelevant. Until then, or if the kernel goes tickless but limits the resolution of timers for efficiency, the value of HZ is still relevant.
The resolution will always be limited. That's the nature of digital systems. Unlimited resolution would require real "real" numbers and that's not possible. The nearest you get on a digital system is the floating point APPROXIMATION to real numbers.
Quoted 8 lines
Sure, but HZ will still be irrelevant. There won't be a HZ to report.
Quoted 1 line
IMHO, as I've said several times,
USER_HZshould be changed to be equal to or greater than HZ. In fact, if havingUSER_HZgreater than HZ would still make it unusable for your purposes, I'd change that opinion to sayUSER_HZshould be equal to HZ (or, in other words, cease to exist).It's not possible to change
USER_HZ. There are too many programs with the number hard-coded into the binary.
This is an argument that the tail should be allowed to wag the dog and is not really valid :-)
Quoted 4 lines
The best we could do is make
the HZ userspace macro non-constant, so it callssysconf(_SC_CLK_TCK), and wait a few years until practically all programs being used no longer contain a hard-coded constant. Then we could get rid ofUSER_HZagain.
If USER_HZ is dispensed with the programs will get fixed pretty quick but as long as this concession to buggy programs is made they won't get fixed (because they don't have to be).
Peter
Signature · 4 lines
Dr Peter Williams, Chief Scientist [email protected] Aurema Pty Limited Tel:+61 2 9698 2322 PO Box 305, Strawberry Hills NSW 2012, Australia Fax:+61 2 9699 9174 79 Myrtle Street, Chippendale NSW 2008, Australia http://www.aurema.com
Quoted 4 lines · Peter Williams
Quoted 2 lines
It's not possible to change
USER_HZ. There are too many programs with the number hard-coded into the binary.This is an argument that the tail should be allowed to wag the dog and is not really valid :-)
It is an interesting, but untenable, position that the applications are the tail and the OS is the dog. The OS exists to serve the applications. The applications, are, after all what a user actually DOES with their computer.
It is possible that the current applications which use hardcoded USER_HZ are not important enough, or are easy enough to fix, that the cost in incompatibility is offset by the benefit of providing different behaviour for future applications.
But breaking them for no good reason, and particularly while there is a migration path possible over time which does not break compatibility, seems like a bad idea.
=============================
Tim Bird
Architecture Group Co-Chair
CE Linux Forum
Senior Staff Engineer
Sony Electronics
E-mail: [email protected]
=============================
Quoted 6 lines · Tim Bird
Quoted 4 lines · Peter Williams
Quoted 2 lines
It's not possible to change
USER_HZ. There are too many programs with the number hard-coded into the binary.
Quoted 6 lines
Quoted 1 line
This is an argument that the tail should be allowed to wag the dog and is not really valid :-)
It is an interesting, but untenable, position that the applications are the tail and the OS is the dog. The OS exists to serve the applications. The applications, are, after all what a user actually DOES with their computer.
I guess wagging was a bad analogy. I was thinking in terms of the kernel being the main entity and the programs being peripheral in the sense that the kernel can exist without the programs but the programs can't exist without the kernel.
Quoted 4 lines
It is possible that the current applications which use hardcoded
USER_HZare not important enough, or are easy enough to fix, that the cost in incompatibility is offset by the benefit of providing different behaviour for future applications.
Yes, this is the real point is that the facilities provided by the kernel shouldn't be tailored/compromised to cope with the problems of a couple of buggy programs especially when fixing the programs would be trivial. I don't think the importance of the program is an issue as I doubt that there is any program that is so important that its requirements dictate kernel design.
Quoted 4 lines
But breaking them for no good reason, and particularly while there is a migration path possible over time which does not break compatibility, seems like a bad idea.
Far more important things than these programs have been "broken" by changes in the kernel (I know, I've had to cope with them getting 2.6.X kernels to work with Red Hat 9) but no one complains or suggests that the kernel should revert to its original behaviour. Change is part of progress and has to be coped with not resisted for no good reason.
Peter
Signature · 4 lines
Dr Peter Williams, Chief Scientist [email protected] Aurema Pty Limited Tel:+61 2 9698 2322 PO Box 305, Strawberry Hills NSW 2012, Australia Fax:+61 2 9699 9174 79 Myrtle Street, Chippendale NSW 2008, Australia http://www.aurema.com
Quoted 8 lines · Jamie Lokier
Quoted 7 lines · Albert Cahalan
If you rely on
sysconf(_SC_CLK_TCK)to work, then your software will support:* all systems with a 2.6.xx kernel
* all systems with a 2.4.xx kernel and recent glibc
* all i386 systems running with the default HZ
Quoted 7 lines
Quoted 4 lines
That's quite a bit I suppose. Maybe you have no interest in supporting a 1200 HZ Alpha with an old kernel or glibc. Maybe you don't care about somebody running a 2.2.xx kernel with modified HZ.
I'm still unclear. Does
sysconf(_SC_CLK_TCK), when it is reliable, return HZ orUSER_HZ?
I consider "reliable" to mean it returns whatever is used by /proc and other kernel interfaces. Prior to the 2.6.xx (and late 2.5.xx) kernels USER_HZ did not exist.
On a 2.6.xx kernel, you get back USER_HZ.
On a 2.4.xx kernel with recent glibc, you get back HZ, which works OK since there isn't any HZ to USER_HZ conversion.
On any i386 system with the default HZ, you will get back 100. On older systems, glibc is just giving you a constant value -- so it is correct if your system is an i386 without any non-Linus modifications. An old glibc can only do sysconf(_SC_CLK_TCK) this way.