From owner-svn-src-all@FreeBSD.ORG Sun Feb 19 11:00:24 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8087C106566B; Sun, 19 Feb 2012 11:00:24 +0000 (UTC) (envelope-from listlog2011@gmail.com) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 6C6A38FC08; Sun, 19 Feb 2012 11:00:24 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q1JB0LB5079751; Sun, 19 Feb 2012 11:00:22 GMT (envelope-from listlog2011@gmail.com) Message-ID: <4F40D644.6030500@gmail.com> Date: Sun, 19 Feb 2012 19:00:20 +0800 From: David Xu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 To: Bruce Evans References: <201202190817.q1J8HEm1071390@svn.freebsd.org> <20120219214118.G1461@besplex.bde.org> In-Reply-To: <20120219214118.G1461@besplex.bde.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, David Xu Subject: Re: svn commit: r231906 - head/lib/libthr/thread X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: davidxu@FreeBSD.org List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Feb 2012 11:00:24 -0000 On 2012/2/19 18:52, Bruce Evans wrote: > On Sun, 19 Feb 2012, David Xu wrote: > >> Log: >> Check both seconds and nanoseconds are zero, only checking nanoseconds >> is zero may trigger timeout too early. It seems a copy&paste bug. >> >> Modified: >> head/lib/libthr/thread/thr_umtx.c >> >> Modified: head/lib/libthr/thread/thr_umtx.c >> ============================================================================== >> >> --- head/lib/libthr/thread/thr_umtx.c Sun Feb 19 07:44:38 2012 >> (r231905) >> +++ head/lib/libthr/thread/thr_umtx.c Sun Feb 19 08:17:14 2012 >> (r231906) >> @@ -205,7 +205,7 @@ _thr_umtx_timedwait_uint(volatile u_int >> if (abstime != NULL) { >> clock_gettime(clockid, &ts); >> TIMESPEC_SUB(&ts2, abstime, &ts); >> - if (ts2.tv_sec < 0 || ts2.tv_nsec <= 0) >> + if (ts2.tv_sec < 0 || (ts2.tv_sec == 0 && ts2.tv_nsec <= 0)) >> return (ETIMEDOUT); >> tsp = &ts2; >> } else { >> > > Use timespeccmp()? It is even likely to be faster, since it can do the > comparison in parallel, while the above has to wait for TIMESPEC_SUB() > before doing the comparison, unless the compiler is very smart. > Yes > However, I seem to have done too good a job of keeping kernel time* APIs > out of userland, so timespeccmp() is only available in the kernel, and > there are uglier but more correct unsafe macros like TIMESPEC_SUB() > macros in userland, and various kernel APIs escaped anyway, starting > with the NetBSD timeval ones, which escaped 10-15 years after timevals > should have gone away because they were superseded by timespecs. > > Bruce > Yes, we noticed that all timespec macros are not available for userland, even TIMESPEC_SUB was copied from kernel.