views:

132

answers:

0

I'm using the POSIX function clock_gettime on the monotonic clock and the times that I'm getting back aren't multiples of the result of calling clock_getres on the monotonic clock.

For example, the resolution is being reported as 0s 999848ns and I have gettime result of 29198s 65414236ns (time divided by resolution gives 29,202,504.19487362079036).

The man page for clock_gettime indicates that if you are setting a clock time that is not a multiple of the resolution, the value is truncated to a multiple of res. This implies that the time of the clock is always a multiple of the res.

When examining lots of clock time values, the greatest common divisor of them is 1000ns which is much smaller than the clock resolution value returned by getres.

The reason I care is because I'm implementing a relative timer (i can't use posix timers) and I need to round the time values to the nearest clock quantum to ensure that timer callbacks occur as close to the intended time as possible.

Am I missing something here?

(I'm running on RedHat EL 4.7).