ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/07/24/18:17:24

Message-ID: <68C4CF842BD2D411AC1600902740B6DA02CDC45E@mcoexc02.mlm.maxtor.com>
From: "Dykstra, Sean" <Sean_Dykstra AT maxtor DOT com>
To: "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>
Subject: RE: Cpu speed detection using DJGPP?
Date: Tue, 24 Jul 2001 12:54:30 -0600
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2653.19)
Reply-To: djgpp AT delorie DOT com

I have in the past used the high performance frequency counters that are
part of the Pentium instruction set, and then used the normal timer tick
interrupt to time the counter events and come up with the clock frequency.  

Of course, I make no guarrantee that this algorithm will work in any way or
is correct in any way, but I have used a similar one that worked for me in
the past!  :)  This should get you extremely close, although if you are
multi threading your app you will see variances.

The process is:
1)  Attach to the standard 55msec timer tic interrupt (see DJGPP FAQ),
adding a counter
2)  Detect for pentium timers (see pentium assembly spec)
3)  Check the TSD flag (to make sure that the pentium timers exist)
4)  Get the number of 55msec ticks
5)  Latch the high performance freq timers
6)  Wait some number of 55msec ticks (I have found 9 is pretty good, without
causing a huge delay)
7)  Latch the new time stamp clock
8)  Frequency=(Time2-Time1) / (double) # of ticks waited / (double) 18.2

The only issues I have seen with this so far is certain EMM386 configs
didn't seem to work.  I don't remember the details because it was a few
years ago... Also, this code may/may not work in Windows, as they protect
the pentium counters.  However, this is not a problem, because under Windows
Microsoft provides you with high performance frequency counters as well.

Sean



-----Original Message-----
From: kallekula60 AT hotmail DOT com [mailto:kallekula60 AT hotmail DOT com]
Sent: Monday, July 23, 2001 3:27 PM
To: djgpp AT delorie DOT com
Subject: Cpu speed detection using DJGPP?


How do I go about doing this?

//Dan

- Raw text -


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