delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/21/03:20:56

Message-ID: <8D53104ECD0CD211AF4000A0C9D60AE30130F308@probe-2.acclaim-euro.net>
From: Shawn Hargreaves <ShawnH AT Probe DOT co DOT uk>
To: djgpp AT delorie DOT com
Subject: Re: high resolution timer
Date: Wed, 21 Apr 1999 09:20:28 +0100
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.0.1460.8)
Reply-To: djgpp AT delorie DOT com

Guillermo Rodriguez Garcia writes:
> The problem is that I wanted to code a driver (well, sort of)
> to be used with a few different applications, some of which
> need timer 0 for themselves, so I wanted to use some other
> resource for timing. But I guess I'll have to write some functions
> to use the timer 0 in the driver and provide some timer facilities
> for the underlying applications.

Plug: if you use Allegro, it has timer functions that will do this
for you. It can install multiple callbacks running at different
speeds, and when running in DOS mode, they are accurate down to
the limits of interrupt latency (it constantly reprograms the PIT
to generate interrupts at exactly the right times). This method
doesn't work under win95, so when run in that environment, it just
locks timer 0 to a fixed rate (1/200 of a second), and uses that
to approximate whenever the callbacks need to be triggered.

> But the Pentium clock register depends on the processor clock rate,
> thus it is system-dependet, isn't it? I may be wrong; could you please
> ellaborate this a bit more?

I've never used this in anger, so I might also be wrong, but it seems
like you ought to be able to measure the clock register speed using
PIT timer 0 when your program starts up, and use that information to
calibrate all your future delay times.


	Shawn Hargreaves.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019