Re: time C function and multi-threadedness

From: David Schwartz (davids@webmaster.com)
Date: 04/01/03


From: David Schwartz <davids@webmaster.com>
Date: Mon, 31 Mar 2003 16:01:33 -0800

Joseph Seigh wrote:

> Since getting the time on an Intel system is expensive, unless you have HPET,
> linux probably just dumbs down gettimeofday() resolution to the current timeslice
> dispatch time. If you want higher resolution, you are out of luck unless you
> know how to write your own high resolution timer that gets around the TSC
> skew problem without any performance penalties. It can be done.

        Actually, Linux synchronizes the TSCs and special cases clock changers,
so in most cases, 'gettimeofday' will take the timeslice dispatch time
and add a fudge factor from the current TSC reading to get you fairly
decent accuracy. Ulrich Windl's 'nanokernel' patches will increase this
accuracy dramatically in conjunction with NTP.

        DS



Relevant Pages

  • Re: getting elapsed time with accuracy in milliseconds
    ... What you're trying to do is impossible in pure standard C, ... likely to be very easy if you use some system-specific extension. ... I'm able to get a resolution of upto 1 microsecond. ... I'm glad gettimeofday() worked for you, but just to make sure everyone ...
    (comp.lang.c)
  • Re: time C function and multi-threadedness
    ... >> linux probably just dumbs down gettimeofday() resolution to the current timeslice ... If you want higher resolution, you are out of luck unless you ... > decent accuracy. ... the linux kernel list about this problem a little while back. ...
    (comp.unix.programmer)
  • Re: time C function and multi-threadedness
    ... >> linux probably just dumbs down gettimeofday() resolution to the current timeslice ... If you want higher resolution, you are out of luck unless you ... >> know how to write your own high resolution timer that gets around the TSC ... I assume NTP is used to synchronize the TSC with the CMOS clock or APIC or whatever. ...
    (comp.unix.programmer)
  • Re: ntpd transmit timestamp precision
    ... You make good points, but from the man page for the gettimeofday(), clock_gettimeand others it would be impossible to deliver the values without intimate kernel participation. ... My comment on library functionality is based on the assumption that if gettimeofdayhappens to appear in different libraries, it designates the same routine and performs the same function. ... But, understand the NTP precision value is measured as the time to read the clock, not the resolution of the clock itself. ...
    (comp.protocols.time.ntp)
  • Re: Y2038 and time_t
    ... There's no statement about the resolution; ... |> | needn't even be linear or monotonic. ... binary program is getting the time in 32 bit form, ... struct timeval for the gettimeofday() function) right now. ...
    (comp.unix.programmer)