From owner-freebsd-current@FreeBSD.ORG Mon Oct 31 10:53:46 2005 Return-Path: X-Original-To: freebsd-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 864C816A41F; Mon, 31 Oct 2005 10:53:46 +0000 (GMT) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3CFCA43D4C; Mon, 31 Oct 2005 10:53:46 +0000 (GMT) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [209.31.154.41]) by cyrus.watson.org (Postfix) with ESMTP id B977046B03; Mon, 31 Oct 2005 05:53:45 -0500 (EST) Date: Mon, 31 Oct 2005 10:53:45 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: David Xu In-Reply-To: <4365F687.3070105@freebsd.org> Message-ID: <20051031104949.D11619@fledge.watson.org> References: <81213.1130754398@critter.freebsd.dk> <4365F687.3070105@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Alexander Leidinger , Poul-Henning Kamp , freebsd-current@freebsd.org Subject: Re: TSC instead of ACPI: powerd doesn't work anymore (to be expected?) 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: Mon, 31 Oct 2005 10:53:46 -0000 On Mon, 31 Oct 2005, David Xu wrote: > In thread program, we have to use clock_gettime, for example a thread > wants to wait for condition variable for two seconds, it has to: > > struct timespec ts; > > clock_gettime(CLOCK_REALTIME, &ts); > ts.tv_sec += 2; > pthread_cond_wait(&cond, &mtx); > > problem is who really cares time precise? how many people are really > handling realtime critical tasks? this is really an unpleasant side > effect that a simple syscall can stall cpu. The questions are: how good is good enough? And for what? The problem here is that while pthread_cond_wait() can afford to accept low resolution, the same clock retrieval interface is also used for things like scientific measurement. So it sounds like the real mistake was the specification for the thread API: while timespec is the New Way for time-related interfaces, this approach has coalesced precision time measurement and "how long to sleep for" time measurement. Moving to HZ incrementing of the clock probably exceeds the quality reduction that makes sense for clock_gettime(), but moving to a roughly sync'd TSC clock (such as the Linux approach) probably doesn't. Robert N M Watson