Re: Timers and timing, was: MySQL Performance 6.0rc1

From: Daniel Eischen <deischen_at_freebsd.org>
Date: Sat, 29 Oct 2005 10:38:20 -0400 (EDT)
On Sat, 29 Oct 2005, David Xu wrote:

> M. Warner Losh wrote:
>
> >Does this mean I can have a 1s wait, jump time back an hour and that
> >the timeout will happen in a little under 1s?
> >
> >Warner
> >
> It is almost but not always, there is still a very small race window.

POSIX also says that you are not guaranteed that your event
occurred when you wake up (false wakeup) and that you should
check for the event after waking up.

Speaking of interfaces for time, Solaris has gethrtime() and
gethrvtime():

  http://docs.sun.com/app/docs/doc/817-0692/6mgfnkuga?q=gethrtime&a=view

    The gethrtime() function returns the current high-resolution
    real time. Time is expressed as nanoseconds since some
    arbitrary time in the past; it is not correlated in any way to
    the time of day, and thus is not subject to resetting or
    drifting by way of adjtime(2) or settimeofday(3C). The hi-res
    timer is ideally suited to performance measurement tasks, where
    cheap, accurate interval timing is required.

    The gethrvtime() function returns the current high-resolution
    LWP virtual time, expressed as total nanoseconds of execution
    time. This function requires that micro state accounting be
    enabled with the ptime utility (see proc(1)).

    The gethrtime() and gethrvtime() functions both return an
    hrtime_t, which is a 64-bit (long long) signed integer.

We've been using gethrtime() for timestamps in our Solaris
applications for several years.  As an API, the autoconf
scripts might already detect it.

-- 
DE
Received on Sat Oct 29 2005 - 12:38:29 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:46 UTC