Re: nanosleep returning early

From: Chuck Swiger <cswiger_at_mac.com>
Date: Thu, 22 Jul 2004 02:01:53 -0400
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
Received on Thu Jul 22 2004 - 04:02:04 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:02 UTC