Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Oct 2005 10:38:20 -0400 (EDT)
From:      Daniel Eischen <deischen@freebsd.org>
To:        David Xu <davidxu@freebsd.org>
Cc:        current@freebsd.org, pertti.kosunen@pp.nic.fi, phk@phk.freebsd.dk, rwatson@freebsd.org, "M. Warner Losh" <imp@bsdimp.com>, jura@networks.ru
Subject:   Re: Timers and timing, was: MySQL Performance 6.0rc1
Message-ID:  <Pine.GSO.4.43.0510291024120.16254-100000@sea.ntplx.net>
In-Reply-To: <43632D9A.30201@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.43.0510291024120.16254-100000>