From owner-freebsd-current@FreeBSD.ORG Sat Oct 29 05:21:49 2005 Return-Path: X-Original-To: current@FreeBSD.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8850D16A41F; Sat, 29 Oct 2005 05:21:49 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2311E43D45; Sat, 29 Oct 2005 05:21:49 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (localhost.village.org [127.0.0.1] (may be forged)) by harmony.bsdimp.com (8.13.3/8.13.3) with ESMTP id j9T5JNli066897; Fri, 28 Oct 2005 23:19:23 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Fri, 28 Oct 2005 23:19:27 -0600 (MDT) Message-Id: <20051028.231927.71089518.imp@bsdimp.com> To: davidxu@FreeBSD.org From: "M. Warner Losh" In-Reply-To: <43630215.9050700@freebsd.org> References: <4362CBC2.8050602@freebsd.org> <20051028.221825.90826015.imp@bsdimp.com> <43630215.9050700@freebsd.org> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Fri, 28 Oct 2005 23:19:24 -0600 (MDT) 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 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Oct 2005 05:21:49 -0000 In message: <43630215.9050700@freebsd.org> David Xu writes: : 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. 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