From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JyVvM-0002GN-JO for mharc-grub-devel@gnu.org; Tue, 20 May 2008 13:46:56 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JyVvL-0002G1-EA for grub-devel@gnu.org; Tue, 20 May 2008 13:46:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JyVvJ-0002FG-Ur for grub-devel@gnu.org; Tue, 20 May 2008 13:46:55 -0400 Received: from [199.232.76.173] (port=33727 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JyVvJ-0002F2-Nd for grub-devel@gnu.org; Tue, 20 May 2008 13:46:53 -0400 Received: from gateway07.websitewelcome.com ([67.18.53.18]:35371) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1JyVvJ-0008O0-EV for grub-devel@gnu.org; Tue, 20 May 2008 13:46:53 -0400 Received: (qmail 27576 invoked from network); 20 May 2008 17:52:34 -0000 Received: from gator297.hostgator.com (74.53.228.114) by gateway07.websitewelcome.com with SMTP; 20 May 2008 17:52:34 -0000 Received: from [146.187.134.203] (port=60682 helo=localhost) by gator297.hostgator.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.68) (envelope-from ) id 1JyVvF-00044T-U2 for grub-devel@gnu.org; Tue, 20 May 2008 12:46:50 -0500 Date: Tue, 20 May 2008 10:46:46 -0700 From: Colin D Bennett To: grub-devel@gnu.org Message-ID: <20080520104646.18dfaf47@gibibit.com> In-Reply-To: <20080512093354.2770e1cf@gibibit.com> References: <20080512093354.2770e1cf@gibibit.com> X-Mailer: Claws Mail 3.4.0 (GTK+ 2.12.9; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/lAWebzjABU7wr97kkhAAq9F"; protocol="application/pgp-signature"; micalg=PGP-SHA1 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator297.hostgator.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - gibibit.com X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Subject: Re: Higher resolution timers X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 May 2008 17:46:55 -0000 --Sig_/lAWebzjABU7wr97kkhAAq9F Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Mon, 12 May 2008 09:33:54 -0700 Colin D Bennett wrote: > I think that using the TSC (w/ RDTSC instruction) and calibrating it > with a quick 2-3 RTC tick loop at startup might be the easiest option. Just wondered if something like this would be a practical way to go: /*******************************************************************/ /* How many ticks to use for calibration loop. (>=3D 1) */ #define CALIBRATION_TICKS 2 /* Output: Number of TSC cycles per second. */ grub_uint64_t tsc_cycles_per_second; void grub_timer_tsc_calibrate(void) { /* Calibrate to real time (relative, not absolute). */ grub_uint64_t start_tsc; grub_uint64_t end_tsc; grub_uint32_t initial_tick; grub_uint32_t start_tick; grub_uint32_t end_tick; /* Wait for the start of the next tick; we'll base out timing off this edge. */ initial_tick =3D grub_get_rtc(); do=20 { start_tick =3D grub_get_rtc(); } while (start_tick =3D=3D initial_tick); start_tsc =3D rdtsc(); /* Wait for the start of the next tick. This will be the end of the 1-tick period. */ do=20 { end_tick =3D grub_get_rtc(); } while (end_tick - start_tick < CALIBRATION_TICKS); end_tsc =3D rdtsc(); tsc_cycles_per_second =3D=20 (end_tsc - start_tsc) / (end_tick - start_tick)=20 * GRUB_TICKS_PER_SEC; } /*******************************************************************/ Colin --Sig_/lAWebzjABU7wr97kkhAAq9F Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkgzDooACgkQokx8fzcGbYeR2wCgoQuq1V+3MXkunvhOny0kDuT9 qH4Ani5j2ey2vEZ3Dzf5C1s9/oe/7Sn/ =6FIv -----END PGP SIGNATURE----- --Sig_/lAWebzjABU7wr97kkhAAq9F--