View topic - Reading CPU clock speed

Reading CPU clock speed

anything that doesn't fit to other groups.

Reading CPU clock speed

Postby rnielsen » Tue Jul 23, 2002 5:22 pm

I am writing an application where I need the CPU clock speed, I tried the qnx_osinfo() but the this doesen't give a valid speed with modern processors.

Can anyone help me with getting the clock speed from elsewhere, the BIOS or .. ????

Thanks.
rnielsen
New Member
 
Posts: 6
Joined: Tue Jul 23, 2002 4:14 pm

Postby noc » Tue Jul 23, 2002 6:38 pm

Have you looked at the source code for SPIN (you can find it under "WebLinks" section? Maybe it can give you some ideas.
By the way, are you on qnx4 or qnx6?
noc
Senior Member
 
Posts: 1634
Joined: Sat Jul 06, 2002 4:34 am

Postby rnielsen » Tue Jul 23, 2002 7:04 pm

We are running QNX 4.25.

What is SPIN ? I am VERY green in the QNX area...... There are tons of utilities under dos and windows who can detect the processor type, any ideas to how that is done ?
rnielsen
New Member
 
Posts: 6
Joined: Tue Jul 23, 2002 4:14 pm

Postby Admin » Tue Jul 23, 2002 9:02 pm

Code: Select all
From the docs for qnx_osinfo():

long unsigned cpu_features
cpu_features & 0xFFF gives the CPU speed, in Mhz.



but as you mentioned, it may not work for the modern processors. when 4.5 GHz CPUs come on the scene they will show up as 500 MHz.
don't know if QSSL will fix it, or maybe it is time for you to upgrade to qnx6.

Code: Select all
the other place to look is the cycles_per_sec in the timesel.

Code like:

#include <sys/osinfo.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <i86.h>

void main()
{
  struct _osinfo osinfo;
  struct _timesel far *ts;
  long unsigned cycles_per_sec;

  qnx_osinfo( 0, &osinfo );

  ts = MK_FP( osinfo.timesel, 0 );

  cycles_per_sec = ts->cycles_per_sec;

  printf("speed is %d Mhz\n", osinfo.cpu_features & 0xFFF );
  printf("cycles is %d\n", cycles_per_sec );
}

But, that is an unsigned long, so it will also wrap around 4G speed.
So, it doesn't help much either.

Admin
Site Admin
 
Posts: 41
Joined: Tue Jul 02, 2002 2:06 pm

Postby rnielsen » Tue Jul 23, 2002 10:20 pm

First, I must get a new view of what a modern processor is...... the fastest we are running are K6's at 500MHz. :roll:

> the other place to look is the cycles_per_sec in the timesel.

WOW That was just what i was looking for... I actually got a reading of 501 MHz, thanks alot.....

> But, that is an unsigned long, so it will also wrap around 4G speed.
> So, it doesn't help much either.

I don't think we will be using processors above 4GHz in near future, the next base system will be based on a PIII @ 750 MHz..... the current system has just been upgraded from PI @ 133 to this K6 @ 500 after 6-7 years of service.

BTW... osinfo.cpu gave me 12759 and osinfo.cpu_features gave me 1104 on that K6 processor. These values seemed a little off, even when AND'ed with 0xFFF.
rnielsen
New Member
 
Posts: 6
Joined: Tue Jul 23, 2002 4:14 pm


Return to General Programming

Who is online

Users browsing this forum: No registered users and 5 guests