Re: Clock monotonic a suggestion

george anzinger (george@mvista.com)
Fri, 21 Mar 2003 11:18:55 -0800


Martin Waitz wrote:
> On Thu, Mar 20, 2003 at 04:16:13PM -0800, george anzinger wrote:
>
>>Define CLOCK_MONOTONIC to be the same as
>>(gettimeofday() + wall_to_monotonic).
>
>
> why don't you simply use asm("rdtsc") ?
> (ok, you should make sure that you always ask the same processor and
> stuff, but using the built in TSC seems to do everything you want...)
>
>
I don't really understand how :(

I want a tick on CLOCK_MONOTONIC to be the same size as a tick on
gettimeofday() over the life of the system. I.e. lock step. The only
difference is that CLOCK_MONOTONIC can not be set, so, if we use the
above, wall_to_monotonic must be adjusted when the gettimeofday()
clock is set (but not when it is "adjusted" by NTP).

asm("rdtsc") is, first of all, only useful on x86 platforms,
CLOCK_MONOTONIC is in the POSIX clocks and timers code and in all
platforms. Second, each platform has an equivalent, best guess, way
of filling in the time information below the 1/HZ level (and yes, some
x86 platforms use TSC) already in the gettimeofday() code. Except
that the system settime code is platform dependent, this solution is
platform independent.

-- 
George Anzinger   george@mvista.com
High-res-timers:  http://sourceforge.net/projects/high-res-timers/
Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/