From owner-cvs-src@FreeBSD.ORG Sat Oct 22 11:32:02 2005 Return-Path: X-Original-To: cvs-src@FreeBSD.org Delivered-To: cvs-src@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 863B816A41F; Sat, 22 Oct 2005 11:32:02 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailout2.pacific.net.au (mailout2.pacific.net.au [61.8.0.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id D6E5B43D48; Sat, 22 Oct 2005 11:32:01 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.0.87]) by mailout2.pacific.net.au (8.13.4/8.13.4/Debian-3) with ESMTP id j9MBW0ih032578; Sat, 22 Oct 2005 21:32:00 +1000 Received: from epsplex.bde.org (katana.zip.com.au [61.8.7.246]) by mailproxy2.pacific.net.au (8.13.4/8.13.4/Debian-3) with ESMTP id j9MBVuBk012393; Sat, 22 Oct 2005 21:31:58 +1000 Date: Sat, 22 Oct 2005 21:31:57 +1000 (EST) From: Bruce Evans X-X-Sender: bde@epsplex.bde.org To: Poul-Henning Kamp In-Reply-To: <34506.1129974516@critter.freebsd.dk> Message-ID: <20051022205219.O1843@epsplex.bde.org> References: <34506.1129974516@critter.freebsd.dk> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, Andre Oppermann , cvs-all@FreeBSD.org Subject: Re: Timekeeping [Was: Re: cvs commit: src/usr.bin/vmstat vmstat.c src/usr.bin/w w.c] X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Oct 2005 11:32:02 -0000 On Sat, 22 Oct 2005, Poul-Henning Kamp wrote: > In message <20051022185422.Q8268@delplex.bde.org>, Bruce Evans writes: > >> What's a UTC delta? Deltas don't (shouldn't) depend on the calendar. > > As easy as it would be to stick our head in the sand, ignore > international treaties,geophysics and astronomy, point to POSIX and > ignore leapseconds, it is not an feasible way out for us as an > operating system project. > > UTC deltas does depend on the calendar for now. Um, my question was rhetorical. We don't have times in UTC, so calandars are irrelvant. If we had times in UTC, then the right way to determine the delta time seems to be to convert the times to time_t's using timegm(), then subtract using difftime(). Times in UTC cannot be simply be subracted by subtracting in minutes and multiplying by 60, etc. But we can just use difftime(). Provided difftime() actually works. > There is proposal from USA to make them DTRT pending in ITU-R Working > Party 7A, but it is meeting fierce opposition from astronomers and > geophysicists who hold the position that we can just ignore computers They already DTRT IMO. It is what the astronomers want. > Until the future of leapseconds are resolved, something that could > easily take 25 years, we have to deal with them. > > So an UTC offect contains any leap seconds we are aware off, and > consequently, it depends on the calendar. Sure, but we don't have UTC. We have broken time_t's for real times but non-broken time_t's for monotonic times. To subtract these times, the opposite methods to the ones stated by Andre should work (but don't): numerical deltas don't work for either UTC or real times -- they don't work for UTC because UTC isn't numeric, and they don't work for real times since POSIX left out the leap seconds -- difftime() should work for subtracting real times; OTOH, numerical deltas work for monotonic times while difftime() doesn't -- although difftime() takes time_t's as args you can't pass the time_t's given by CLOCK_MONOTONIC to it, since the latter are differences relative to an undocumented start time but difftime() only handles absolute times. Bruce