[reSIProcate] Timers: why system time?

Justin Matthews jmatthewsr at gmail.com
Tue May 19 07:46:17 CDT 2009


Hi,

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


Windows
=========

* _RESIP_WINDOWS_MONOTONIC_CLOCK  enables/disables the monotonic timer.  If
disabled, the current ::GetSystemTime is used.

* The default on Windows Vista and beyond is to use ::GetTickCount64().  No
special handling is required when using this function.

* The default on Windows versions < Vista is GTCLockDuringRange::GTC64().
This implementation is the one given by Alexander, based on his final
comments below.

* An alternate implementation GTCInterlocked is given and is intended to
decrease the frequency that the timer must be called and avoid locking on a
mutex.

* A third alternative is to simply lock each time the timer is called
(GTCLock)

* When not running on Vista or higher, GTCLockDuringRange is the default
because the GTCInterlocked requires the CMPXCHG8B instruction, which was
introduced in the intel pentium and AMD K5 and is only supported, without
assembly, using an intrinsic visual c++ function that is only available in
visual studio 2005 or higher.

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.

=========

Comments?

Thanks,

-justin

-----Original Message-----
From: slgodin at gmail.com [mailto:slgodin at gmail.com] On Behalf Of Scott Godin
Sent: Wednesday, November 05, 2008 2:40 PM
To: Alexander Altshuler
Cc: Justin Matthews; Byron Campen; Adam Roach; resiprocate-devel
Subject: Re: [reSIProcate] Timers: why system time?

I think a solution that does not depend on how often getTimeMs is
called is preferred, given that it doesn't have a huge hit on
performance.  This makes the Timer class more usable as a general
utiltiy fn, if used outside of the stack.

Scott

On Wed, Nov 5, 2008 at 2:26 PM, Alexander Altshuler <alt at kaluga.ru> wrote:
> Hi All
>
> The requirements for offered Win32 timer wrap around problem:
> Timer::getTimeMs() must be reasonable often called.
>
> The solution:
> - redefine SipStack::getTimeTillNextProcessMS() that it will return
> 0xfff maximum for example.
>
> PS: Timer::msTillNextWrapAroundTimer() stuff I posted today will be
> unnecessary.
>
> Regards
> Alexander Altshuler
> http://xeepe.com
>
> _______________________________________________
> resiprocate-devel mailing list
> resiprocate-devel at resiprocate.org
> https://list.resiprocate.org/mailman/listinfo/resiprocate-devel
>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Timer.cxx
URL: <http://list.resiprocate.org/pipermail/resiprocate-devel/attachments/20090519/6ef9d9ec/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Timer.hxx
URL: <http://list.resiprocate.org/pipermail/resiprocate-devel/attachments/20090519/6ef9d9ec/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: SipStack.cxx
URL: <http://list.resiprocate.org/pipermail/resiprocate-devel/attachments/20090519/6ef9d9ec/attachment-0002.ksh>


More information about the resiprocate-devel mailing list