Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Oct 2005 13:01:09 +0800
From:      David Xu <davidxu@freebsd.org>
To:        "M. Warner Losh" <imp@bsdimp.com>
Cc:        pertti.kosunen@pp.nic.fi, phk@phk.freebsd.dk, rwatson@FreeBSD.org, current@FreeBSD.org, jura@networks.ru
Subject:   Re: Timers and timing, was: MySQL Performance 6.0rc1
Message-ID:  <43630215.9050700@freebsd.org>
In-Reply-To: <20051028.221825.90826015.imp@bsdimp.com>
References:  <35696.1130538037@critter.freebsd.dk>	<20051029005719.I20147@fledge.watson.org>	<4362CBC2.8050602@freebsd.org> <20051028.221825.90826015.imp@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
M. Warner Losh wrote:

>: thread libraries use clock_gettime, this becauses there is
>: pthread_cond_timedwait and other synchronization objects
>: like rwlock, and mutex all have a timeout version, I think
>: pthread_cond_timedwait is mostly used in some applications,
>: though normally, application is not looking for high accuracy.
>: they will get benefit from the clock_gettime speed improvement.
>
>And unfortuantely, the argument that needs to be passed to abstime is
>unspecified, at leas tin our man page.  Also unfortuantely,
>CLOCK_REALTIME seems to be what's required here (our man page just
>says 'if the system time reaches the time specified in abstime'),
>rather than CLOCK_MONOTONIC so jumps in system time can cause
>previously short timeouts to become rather large timeouts...  This is
>a flaw in the API. :-(
>
>Warner
>  
>
I would rather to think it is brokeness of POSIX thread API specification,
in real world, nobody uses the timeout as an absolute timestamp,  almost
all applications are doing relative timeout sleep, if implementor 100%
respects POSIX spec,  he will break many applications.
libthr supports pthread_condattr_setclock, you can select CLOCK_MONOTONIC
for pthread_cond_timedwait, but internally, all absolute timeout waits are
converted to relative.

David Xu




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