what clock is used by select()/HZ ?
rizzo at iet.unipi.it
Fri Sep 4 20:08:56 UTC 2009
I am running a kernel (8.0) with HZ=5000 trying to generate
packets which are apart from each other by something that is
not an exact multiple of 1ms . I have a modified ping version
which essentially accepts a microsecond spec, loops around
select() and tries to send a packet at precise intervals
(taking care not to accumulate errors).
running it with
./ping -i 0.050200 some.host
and looking at the tcpdump output captured on the same host, i see
that packets get out of the system at intervals that (according to
the tcpdump timestamps are .050121 (60% of them) or .050322 (40%
of them) seconds apart (values are scattered within 10us of each
of the two values).
Overall the average delta is correct, but individual samples are not.
The system reports the following values:
kern.timecounter.choice: TSC(-100) HPET(900) ACPI-safe(850) i8254(0) dummy(-1000000)
kern.timecounter.tick: 5 # (not sure what this means)
The only way i can explain the differences in the delays is that
the internal value of HZ is slightly different than the correct
value (50121/50200 or 50322/50200 times 5000) due to some approximation
in the divider used to generate the peridic interrupt, whereas
gettimeofday() is reasonably correct and prevents the accumulation
However, HPET (which seems to be the one used) is a multiple of 5000
so the divider should be correct, and i cannot figure out what other
clock source could cause, due to a rounding error in the divisor,
such a large difference (50121/50200 or 50322/50200)
Any ideas ?
More information about the freebsd-current