Re: Timers and timing, was: MySQL Performance 6.0rc1
From: Daniel Eischen (deischen_at_freebsd.org)
Date: 10/29/05
- Previous message: Victor Balada Diaz: "FreeBSD 6.0 -RC1 doesn't detect my hard drive"
- In reply to: David Xu: "Re: Timers and timing, was: MySQL Performance 6.0rc1"
- Next in thread: Robert Watson: "Re: Timers and timing, was: MySQL Performance 6.0rc1"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 29 Oct 2005 10:38:20 -0400 (EDT) To: David Xu <davidxu@freebsd.org>
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 _______________________________________________ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
- Previous message: Victor Balada Diaz: "FreeBSD 6.0 -RC1 doesn't detect my hard drive"
- In reply to: David Xu: "Re: Timers and timing, was: MySQL Performance 6.0rc1"
- Next in thread: Robert Watson: "Re: Timers and timing, was: MySQL Performance 6.0rc1"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]