Subject: Re: POSIX timer_settime() dosn't set timer in some cases (lost
To: Jason Thorpe <thorpej@wasabisystems.com>
From: Frederick Bruckman <fredb@immanent.net>
List: tech-kern
Date: 09/01/2004 23:46:23
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...
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