]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Use a periodic itimer instead of repeated calls to alarm() in
authorbde <bde@FreeBSD.org>
Tue, 27 Feb 2007 04:54:33 +0000 (04:54 +0000)
committerbde <bde@FreeBSD.org>
Tue, 27 Feb 2007 04:54:33 +0000 (04:54 +0000)
commit3ee0d09a443f80fc57dc791114562e66b6856c71
treeff742b8b2e502413667eeed2507cb703f839ea09
parent05b92097cb751ac3e6ba126eed272f954f9c7210
Use a periodic itimer instead of repeated calls to alarm() in
sidewaysintpr().  This increases the accuracy of the per-interval
counts when they are interpreted as rates.  Repeated calls to alarm(n)
give an average interval that is about 2 ticks larger than n and has
a large variance.  Periodic itimers normally get the average almost
right but have similarly large variance (due to scheduling delays).

Statistics utilities should use clock_gettime() to determine the
actual interval, but it is still useful to maximize the accuracy of
the interval, especially for cases like netstat -w where counts are
displayed so the program cannot hide the inaccuracy in a rate
conversion.
usr.bin/netstat/if.c