nanosleep returning early
Chuck Swiger
cswiger at mac.com
Wed Jul 21 23:02:04 PDT 2004
John Birrell wrote:
[ ... ]
> Bruce, have you seen this document: <http://www.dragonflybsd.org/docs/nanosleep/>?
> I'm not looking for a critique here. The document talks about the sleep
> overruns in various operatingg systems. There is a patch that was applied
> to DragonFly which a[p]plies to the FreeBSD code base too.
This was a good link, BTW, John: thanks for the pointer. I've created diffs
of containing the first part of the changes for -CURRENT and -STABLE at:
http://www.pkix.net/~chuck/timer/timer-STABLE.diff
http://www.pkix.net/~chuck/timer/timer-CURRENT.diff
On a 4.10 P3-grade machine using HZ=1000, I get the following graphs for 200
seconds worth of the "wakeup.c" program:
http://www.pkix.net/~chuck/timer/wakeup001.gif
...so the changes reduce the latency seen from around 1.2ms to around 0.46ms.
The aliasing problem is still clearly visible since I haven't had a chance to
test the second set of changes. Matt's PLL code in i386/isa/clock.c has
diverged a fair amount and the Dfly code apparently no longer works on
486-grade hardware due to using 8254 timing modes, if I understand what's
going on correctly, but just the improvement above seems quite worthwhile.
I'm going to retest using HZ=100, too, to see what's going on under default
conditions. Please note that the wakeup interval after the patch can go very
slightly negative (by 5-10 us): I'm not sure whether my hardware clock is off
or a little flaky in the microsecond range, whether there is some issue with
nanosleep() waking things up a little early, or whether the diffs need to be
tweaked more.
Testing on a few other machines would be good. :-)
--
-Chuck
More information about the freebsd-current
mailing list