Subject: Re: ps/2 mouse timeout problems
To: None <tech-kern@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 09/03/2002 11:51:46
On Tue, Sep 03, 2002 at 04:43:59PM +0700, Robert Elz wrote:
>   | +	if (max_delay == 0) {
>   | +		/* round 25ms up to next value of hz granularity */
>   | +		max_delay = (25*hz+999)/1000;	/* calc ticks */
>   | +		max_delay *= 1000000/hz;	/* convert to usec */
>   | +	}
> 
> You don't need all that rounding noise - in this scheme the comparisons
> are done using microseconds.
> 
> It is perfectly safe to ask for 25000 microseconds, regardless of the
> actual timer jumping 0, 10000, 20000, 30000 - when it gets to 30000 it
> will be bigger than 25000 and the timeout will go off.

not quite, if the first byte arrived at 9999, you would timestamp
it with 0. When the next arrives at 30001 you calculate a delay
of 30000 instead of the actual value of 20002.

This means you need to add 1/hz to the max_delay value.
Alternatively I don't think this needs timeout to be accurate, just
large enough.  So taking max_delay out to 100ms will almost certainly
have no detrimental effects, and then the value of hz is immaterial.

	David

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