From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JyVWE-0001F2-HB for mharc-grub-devel@gnu.org; Tue, 20 May 2008 13:20:58 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JyVWB-00019c-M0 for grub-devel@gnu.org; Tue, 20 May 2008 13:20:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JyVWA-00016J-2C for grub-devel@gnu.org; Tue, 20 May 2008 13:20:55 -0400 Received: from [199.232.76.173] (port=59295 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JyVW9-00015r-Pk for grub-devel@gnu.org; Tue, 20 May 2008 13:20:53 -0400 Received: from gateway16.websitewelcome.com ([69.56.233.8]:33656) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1JyVW9-0001HA-J2 for grub-devel@gnu.org; Tue, 20 May 2008 13:20:53 -0400 Received: (qmail 4313 invoked from network); 20 May 2008 17:22:57 -0000 Received: from gator297.hostgator.com (74.53.228.114) by gateway16.websitewelcome.com with SMTP; 20 May 2008 17:22:57 -0000 Received: from [146.187.134.203] (port=44287 helo=localhost) by gator297.hostgator.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.68) (envelope-from ) id 1JyVW4-000200-Uo for grub-devel@gnu.org; Tue, 20 May 2008 12:20:49 -0500 Date: Tue, 20 May 2008 10:20:47 -0700 From: Colin D Bennett To: grub-devel@gnu.org Message-ID: <20080520102047.23b0456e@gibibit.com> In-Reply-To: <483058D9.6060701@nic.fi> References: <20080512093354.2770e1cf@gibibit.com> <483058D9.6060701@nic.fi> X-Mailer: Claws Mail 3.4.0 (GTK+ 2.12.9; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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:20:55 -0000 On Sun, 18 May 2008 19:27:05 +0300 Vesa J=C3=A4=C3=A4skel=C3=A4inen wrote: > 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. >=20 > Hi Colin, >=20 > What kind of accuracy would you need? >=20 > I am just wondering if you just define function like: >=20 > grub_uint64_t > grub_timer_[nu]time(void); >=20 > This could return time in nanoseconds, or microseconds from epoch. >=20 > Then during grub init you would call some platform function to=20 > initialize time (calibrate when using rdtsc), and set proper offset=20 > value so you get correct time when asking for time. On every system > it would return time in this format, but granularity would be > different. >=20 > This could be: >=20 > void > grub_timer_init(void) >=20 > What do you think? Vesa, It sounds good. Actually, for the kind of the situations I am thinking of, high resolution timing is not required to be based on any absolute real time, so we would not necessarily need to base it on RTC time. Synchronizing it to RTC time would probably not be difficult, but I thought I would mention what my requirements will be. Here is the kind of situation I envision, in an event loop that handles accepting user input and updating the screen at regular intervals (possibly at 30 to 60 frames/sec, hence the need for higher resolution timers) to support the user interface: /* Event loop */ grub_uint32_t nextframe_time =3D 0; grub_uint32_t now; while (1) { now =3D grub_timer_utime(); if (now >=3D nextframe_time) { /* Schedule the next frame. */ nextframe_time =3D now + 1000000 / FRAMES_PER_SEC; do_animation_step(); } if (key_is_pressed()) { /* Handle key presses... */ } } So all I care about is the value relative to other calls to grub_timer_utime() during a particular runtime of grub. It could start at 0 if that is easier, but either way is fine. Colin