From owner-freebsd-arch Wed Oct 31 12:54:33 2001 Delivered-To: freebsd-arch@freebsd.org Received: from netau1.alcanet.com.au (ntp.alcanet.com.au [203.62.196.27]) by hub.freebsd.org (Postfix) with ESMTP id 81C9137B401 for ; Wed, 31 Oct 2001 12:54:21 -0800 (PST) Received: from mfg1.cim.alcatel.com.au (mfg1.cim.alcatel.com.au [139.188.23.1]) by netau1.alcanet.com.au (8.9.3 (PHNE_22672)/8.9.3) with ESMTP id HAA03698; Thu, 1 Nov 2001 07:53:51 +1100 (EDT) Received: from gsmx07.alcatel.com.au by cim.alcatel.com.au (PMDF V5.2-32 #37641) with ESMTP id <01KA6KOPBHWWVFIYV8@cim.alcatel.com.au>; Thu, 1 Nov 2001 07:53:40 +1100 Received: (from jeremyp@localhost) by gsmx07.alcatel.com.au (8.11.1/8.11.1) id f9VKrlp94849; Thu, 01 Nov 2001 07:53:47 +1100 Content-return: prohibited Date: Thu, 01 Nov 2001 07:53:47 +1100 From: Peter Jeremy Subject: Re: 64 bit times revisited.. In-reply-to: <200110261914.PAA17908@devonshire.cnchost.com>; from bakul@bitblocks.com on Fri, Oct 26, 2001 at 12:15:00PM -0700 To: Bakul Shah Cc: Poul-Henning Kamp , Peter Wemm , arch@FreeBSD.ORG Mail-Followup-To: Bakul Shah , Poul-Henning Kamp , Peter Wemm , arch@FreeBSD.ORG Message-id: <20011101075347.A94706@gsmx07.alcatel.com.au> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG [Resend due to mail bouncing] On 2001-Oct-26 12:15:00 -0700, Bakul Shah wrote: >> >Okay, how about this? Define N types that will be >> >*exactly* the same on *all* machines: >> > >> > time_t 32 bits (1 second resolution, upto yr 2038) >> > nstime64_t 64 bits (10^-9 second resolution, upto yr 2554) >> >> Should be 1/2^32 resolution or you have a math nightmare dividing >> by 1000000000 all the time. > >On my 500Mhz PIII it takes about 4.6ns to divide a 64 bit >number by a 64 bit 10^9. Are you sure? I've just _measured_ it on a PIII-600 and came up with 211nsec (averaged over 1e7 loops). Keep in mind that this solution has to also work in embedded applications - which are several orders of magnitude slower than this. >> here: resolution 1/2^64 second. >> >> Decimal computers lost the race and they ai2768n't coming back. We want >> arithmetic on binary computers to be fast and simple. > >Most everyone uses powers of ten for timing units. No-one is suggesting that I/O has to be in binary. There's no reason why you can't convert the internal binary format into decimal. EDSAC managed this more than 50 years ago. Note that it's _easier_ to convert a binary fraction to an arbitrary number of decimal places than converting a integral number of zotto (or whatever) seconds to decimal (feel free to consult [1] if you disagree). There are two logical timestamp formats for a binary computer: 1) Fixed point seconds with M bits to the left of the binary point and N bits to the right. 2) Integral number of (fractional second units). (As used on the IBM System 360 and later). Both of which are far better than having programs full of t1.tv_sec -= t2.tv_sec; if ((t1.tv_usec -= t2.tv_usec) < 0) { t1.tv_usec += 1000000; t1.tv_sec--; } The former is probably a better choice because it's easier to expand to the right (as things speed up) and you can more cheaply extract lower-precision variants. Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message