< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index Next in Thread >

Re: [reSIProcate] Timers: why system time?




On Tue, May 19, 2009 at 3:46 PM, Justin Matthews <jmatthewsr@xxxxxxxxx> wrote:
Hi,

Attached is a proposed mod to enable monotonic Timer's on Windows and *unix.

[snipped windows solution]
 

Non-Windows
=========

* _RESIP_POSIX_MONOTONIC_CLOCK enables the __NR_clock_gettime call.  Note
that on some systems even if _POSIX_MONOTONIC_CLOCK is defined
__NR_clock_gettime may not be, or may require another library (librt?).
Some improvement in enabling this could probably be done in the build
scripts.

Why use _NR_clock_gettime? just use clock_gettime.

To get monotonic time from clock_gettime, you have to call it with CLOCK_MONOTONIC.

To enable the monotonic clock, I suggest to check for CLOCK_MONOTONIC. On the platforms I used it, ether CLOCK_MONOTONIC is not available (arm, crosstool toochain), or _POSIX_MONOTONIC_CLOCK is not defined, but CLOCK_MONOTONIC is (Ubuntu 8.04).

To use the monotonic clock, you have to link with librt (-lrt).

Mac OS X
======

You need to use UpTime() call in DriverServices.h or the routines in <mach/mach_time.h>