15

What is a resolution of jiffie in Linux Kernel?

according to current timer source (cat /sys/devices/system/clocksource/clocksource0/current_clocksource), Linux uses TSC and has nanosecond resolution

according to http://lxr.free-electrons.com/source/include/linux/jiffies.h jiffie is not smaller than 1us, but can be larger.

Is there a way to determine its current resolution.

Effie
  • 259
  • 1
  • 2
  • 4

2 Answers2

10

If you take a look at the man page 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 con‐ stant USER_HZ. User-space applications can determine the value of this constant
using sysconf(_SC_CLK_TCK).

You can inquire the CLK_TCK constant:

$ getconf CLK_TCK
100

This tells you the value of HZ, i.e. 100. This value is the number of jiffies in a second.

References

slm
  • 369,824
2

According to these sources, the resolution for jiffies is 1/HZ (whatever value HZ happens to have):

It is defined in one of the kernel-dependent header files, e.g.,

/usr/include/asm-generic/param.h

which is included from

/usr/include/linux/param.h

and ultimately from <sys/param.h>, which may be in an architecture-specific directory, e.g.,

/usr/include/x86_64-linux-gnu/sys/param.h

The sources make it apparent that it is a compile-time constant and depends on your particular system.

Thomas Dickey
  • 76,765
  • sorry, I need to know "whatever value HZ happens to have" because I need to know the resolution of clock source in TCP and it is in jiffies – Effie Nov 21 '15 at 13:31