How to check HZ in the terminal?

There's no uniform answer to this questions, as in some cases your kernel may be compiled "tickless" and not use a regular timer interrupt at all. But if you're on a traditional kernel and a traditional distro, you can find the current kernel's .config file under /boot with something like grep 'CONFIG_HZ=' /boot/config-$(uname -r).


The value of HZ can be determined like so:

$ getconf CLK_TCK
100

Any of the compile time options of the running kernel can be gleamed using getconf. Keep in mind that HZ is configurable:

$ man 7 time

The value of HZ varies across kernel versions and hardware platforms. On i386 the situation is as follows: on kernels up to and including 2.4.x, HZ was 100 giving a jiffy value of 0.01 seconds; starting with 2.6.0, HZ was raised to 1000, giving a jiffy of 0.001 seconds. Since kernel 2.6.13, the HZ value is a kernel configuration parameter and can be 100, 250 (the default) or 1000, yielding a jiffies value of, respectively, 0.01, 0.004, or 0.001 seconds. Since kernel 2.6.20, a further frequency is available: 300, a number that divides evenly for the common video frame rates (PAL, 25 HZ; NTSC, 30 HZ).

The times(2) system call is a special case. It reports times with a granularity defined by the kernel constant USER_HZ. User-space applications can determine thecvalue of this constant using sysconf(_SC_CLK_TCK).

As is typically the case you may need to trim the _SC_ bit off of the variable name shown in the man pages when inquiring about it using getconf.

Tags:

Linux

Clock