Subject: Re: More on MI kern_microtime.c - 64-bit arith & MIPS
To: Simon Burge <simonb@wasabisystems.com>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 06/02/2003 16:30:22
>  2- Have a way of overriding the
> 	(usec * ci->ci_cc_ms_delta) / ci->ci_cc_denom
>     expression.

Given the code is just trying to scale a 32 bit counter to (about) 13
bits and that moniticity is more important that absolute accuracy
(+/- 1 count is of the order of the cost of the operation) why not do
a multiply by reciprocal?

Ideally you could use the 32x32 multiply and take the upper 32 bits of the
result.  However enough accuracy can (probably) be obtained by doing:
	((usec >> n1) * n2) >> n3
for appropriate n1, n2 and n3.

Lets see, at 100Hz 1 tick is 10000us so n1 = 14 and n3 = 18 allows for
the timer interrupt being delayed by over half a tick. The scaling
has plenty of accuracy since we are genetating an 13bit result from
18 bits.

Indeed, splitting 16/16 might be better on systems without a barrel
shifter...

	David

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