Re: Help with the high res timers

From: George Anzinger
Date: Wed May 04 2005 - 15:44:51 EST


Chris Friesen wrote:
Nishanth Aravamudan wrote:

If I understand your point correctly, I think this is achieved by
TIMERINTERVAL_BITS in my patch (not to claim my patch is function, but
conceptually). No matter what you actually request, the best you can do
is 2^TIMERINTERVAL_BITS nanoseconds, and usually worse because the
tick-rate and timerinterval length do not necessarily line up.


My point is simply that the timer for the next interval should start at the time the timer expires, not the time that userspace picks up the prior expiration. Throttling the timer rate should be done at the time of timer request rather than timer expiry.

If I have usec-accuracy in the timer subsystem, I should be able to set a timer with an interval of 9.999ms and have it remain accurate over time (subject to scheduler jitter, of course). N timer intervals later my timer should expire at (original_time + N*9.999ms + jitter). In this case the error is roughly constant with time.

If the timer doesn't start counting the next interval until the user detects expiry, I'm going to get some non-zero addition to *each* interval such that my timers will not remain accurate over long periods of time. In this case N timer intervals later my timer will expire at (original_time + N*(9.999ms + jitter)) which is a very different thing. Since jitter will always be positive, the error increases with time.

You can, and we do in the main line kernel, keep this accuracy even with missed timer expiries. When a timer is restarted, the actual requested expire time is recalculated. It is adjusted ONLY by the requested repeat time until it results in a time that has yet to come and the number of repeat times it takes is logged in the overrun count for user examination.

Chris
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


--
George Anzinger george@xxxxxxxxxx
High-res-timers: http://sourceforge.net/projects/high-res-timers/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/