Subject: Re: select timeout question
To: Matthew Fincham <matthewf@cat.co.za>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 09/23/2004 07:39:52
> It seems the 1.4 version rounds down, while the 1.5 and up version rounds up
> (but two levels). Can anyone shed some light on this, and if there is a way
> to improve the resolution of the timeouts (asking for a 21ms timeout and
> getting a 40ms timeout is not great).

Given that the code only has the timer interrupts to work with, and that it
is imperative that the delay is 'at least as long at that specified' the
current code is behaving correctly, and 1.4 could give short timeouts.

If the 10ms ticks are t0, t1 etc, then consider what happens if you ask
for a delay of 21ms at time (t1 - 0.1ms). t2 happens at 10.1ms, t3 at 20.1 and
t4 at 30.1 so we must wait until t4.  This means we must wait until t4 if start
the delay anytime between t0 and t1.  So if you are 'just after' t0 you must
wait until t4 - almost 40ms.

The only obvious solution is for the code that converts times to ticks to be
able to determine the 'time to next tick' and include that in the calculation.

	David

-- 
David Laight: david@l8s.co.uk