This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: clock() time travel.
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: PaweÅ Sikora <pluto at agmk dot net>, libc-help at sourceware dot org
- Date: Thu, 16 Jan 2014 11:38:55 -0500
- Subject: Re: clock() time travel.
- Authentication-results: sourceware.org; auth=none
- References: <2a73b22e707bbe6dce3871aacf7d8a69 at agmk dot net>
On 01/16/2014 05:54 AM, PaweÅ Sikora wrote:> Hi,
>
> i've observed on my i3-540 cpu that subsequent clock() calls *sometimes* give smaller number of ticks than previous one.
> is it a known issue?
>
> BR,
> PaweÅ.
>
> % ./timing
> t[current]: 10713902 < t[previous]: 10713903
> zsh: abort (core dumped) ./timing
This is either a compiler or kernel bug.
On glibc click() is just clock_gettime with
CLOCK_PROCESS_CPUTIME_ID followed by the appropriate
divisions to get the correctly rounded result.
Either the kernel accounting is wrong or the compiler
generated code to round the result is non-deterministic.
Try using clock_gettime and compare the values?
Cheers,
Carlos.