Mail Archives: djgpp/2001/07/24/18:17:24
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 -