High Resolution Clocks Inconsistent?

From: Chris (doktorstick_at_gmail.com)
Date: 09/22/04


Date: 22 Sep 2004 09:37:14 -0700

Howdy.

I'm computing the time spent in compute-bounds routine using the
high-resolution clocks in the Linux 2.4 kernel. Specifically, I have
tried CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID through the
clock_gettime() routine to measure user time. The task is
single-threaded so I would expect both to yield the same results.

The problem I run into is that occasionally the timing jumps by 1-N
orders of magnitude. Here are a few runs of test data to illustrate:

. f(x) g(x) factor
---------------------------------
. 16523 22362 1.353
. 17248 22300 1.293
. 17713 22831 1.289
. 16557 21605 1.305
. 20032 23164 1.156
. 16959 2579067 152.077 ** g(x) timing jumps
. 16738 21752 1.300
. 266011 25864 0.097 ** f(x) timing jumps

I have dumped the raw struct timespec data and verified that my
calculation is overflowing or underflowing.

Am I misunderstanding the purpose of these clocks? What is the
solution? Using the HRT patches from the HRT project at sourceforge
are not an option.

Cheers,
Chris