[LAD] Strange gettimeofday behaviour - out of order times.

Paul Davis paul at linuxaudiosystems.com
Thu May 5 00:20:51 UTC 2011


On Wed, May 4, 2011 at 7:11 PM, Tim E. Real <termtech at rogers.com> wrote:
> I discovered gettimeofday occasionally gives me a time value
>  which is less than a previous time value. The value is actually
>  'out of order' and really belongs ahead of a few others,
>  according to examined printouts.
>
> So I tried  clock_gettime(CLOCK_MONOTONIC, ..), same result.

i believe you want CLOCK_REALTIME. however, if CLOCK_MONOTONIC is
malfunctioning and you can prove it with a very small piece of code,
the kernel guys will want to know.

> Still checking some things, maybe there's a reason, the app's fault.
> From what I've read gettimeofday is thread safe, but the incorrect
>  time values are being read by the same thread always.

gettimeofday() is subject to system time corrections (e.g. via NTP).
it is never ever guaranteed to be monotonic.



More information about the Linux-audio-dev mailing list