Subject: Re: POSIX timer_settime() dosn't set timer in some cases (lost accuracy)
To: Frederick Bruckman <fredb@immanent.net>
From: Jason Thorpe <thorpej@wasabisystems.com>
List: tech-kern
Date: 09/02/2004 08:10:27
--Apple-Mail-19--133489690
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII; format=flowed
On Sep 1, 2004, at 9:46 PM, Frederick Bruckman wrote:
> On Wed, 1 Sep 2004, Jason Thorpe wrote:
>
>> On Sep 1, 2004, at 7:41 PM, Frederick Bruckman wrote:
>>
>>> Now, hzto() takes great care to round up, but the nano-second is lost
>>> before getting there in TIMESPEC_TO_TIMEVAL(). Should TS...TV always
>>> round up? It seems, with the present state of affairs, that any
>>> number
>>> of timers in the kernel could be firing slightly too early. There's
>>> no
>>> harm, ever, in a timer firing nanoseconds late (or later), is there?
>>
>> Maybe if you're controlling spark plugs (well, ok, so you're not
>> going to pop a hole in your piston if the timing is slightly
>> retarded)... but, in any case, we're not, so no, I don't think
>> there's any harm in it.
>
> Well, I'm running X and listening to streaming audio with this...
I guess I should clarify... there may be times when you want "truncate"
and times when you want "round". Perhaps we need a TS_TO_TV macro for
each.
>
>
> Index: sys/sys/time.h
> ===================================================================
> RCS file: /cvsroot/src/sys/sys/time.h,v
> retrieving revision 1.41
> diff -u -r1.41 time.h
> --- sys/sys/time.h 6 Sep 2003 22:01:21 -0000 1.41
> +++ sys/sys/time.h 2 Sep 2004 03:03:28 -0000
> @@ -65,7 +65,11 @@
> }
> #define TIMESPEC_TO_TIMEVAL(tv, ts) { \
> (tv)->tv_sec = (ts)->tv_sec; \
> - (tv)->tv_usec = (ts)->tv_nsec / 1000; \
> + (tv)->tv_usec = ((ts)->tv_nsec + 999) / 1000; \
> + if ((tv)->tv_usec >= 1000000) { \
> + (tv)->tv_sec += 1; \
> + (tv)->tv_usec -= 1000000; \
> + } \
> }
>
> /*
>
>
> and no flames are flying out of the carburator. What's surprising to
> me, is that the kernel is exactly the same size with and without, when
> compiled with --march=pentium4.
>
>
> Frederick
>
-- Jason R. Thorpe <thorpej@wasabisystems.com>
--Apple-Mail-19--133489690
content-type: application/pgp-signature; x-mac-type=70674453;
name=PGP.sig
content-description: This is a digitally signed message part
content-disposition: inline; filename=PGP.sig
content-transfer-encoding: 7bit
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)
iD8DBQFBNzfjOpVKkaBm8XkRAp2AAJ9ibr4bOqwbDKw3U6J5dp2UTrSGjwCfegRt
sm9zHhPu0dNw5EztGS8piJ0=
=fDbd
-----END PGP SIGNATURE-----
--Apple-Mail-19--133489690--