Reading system description

For an application, I need to read the system hardware that the OS (QNX 4.25) is running on. More specificaly I would like to be to read the CPU type, clock speed, amount of RAM, HD type e.t.c… can
any of you wizards help me out here ???

Thanks
Rene Nielsen

rnielsen@hns.com wrote:

For an application, I need to read the system hardware that the
OS (QNX 4.25) is running on. More specificaly I would like to be
to read the CPU type, clock speed, amount of RAM, HD type e.t.c… can
any of you wizards help me out here ???

qnx_osinfo() will get you some of that… should get CPU type & speed,
amount of RAM and a bunch of other interesting information.

For disk & network & stuff like that – QNX doesn’t really have a list
of “installed” hardware – but take a look at the output from “sin ver”
which will list the drivers running, and from that you should be able
to get an idea of the hardware around.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

I tried the qnx_osinfo command and there are some of the values that are a bit unclear for me.

We are running QNX 4.25 on a AMD K6/500MHz with 128MB of RAM

Here are the values from the qnx_osinfo command
cpu_speed = 12758
cpu = 586
totmemk = 65152
freememk = 52564
version = 425

The CPU type, and OS version is correct, but the other values memory and cpu speed are a bit off… am I missing something ?

Is there another way to directly read the bios from the motherboard ?

Regards
Rene


On 16 Jul 2002 21:17:01 GMT, David Gibbs <dagibbs@qnx.com> wrote:

rnielsen@hns.com > wrote:
For an application, I need to read the system hardware that the
OS (QNX 4.25) is running on. More specificaly I would like to be
to read the CPU type, clock speed, amount of RAM, HD type e.t.c… can
any of you wizards help me out here ???

qnx_osinfo() will get you some of that… should get CPU type & speed,
amount of RAM and a bunch of other interesting information.

For disk & network & stuff like that – QNX doesn’t really have a list
of “installed” hardware – but take a look at the output from “sin ver”
which will list the drivers running, and from that you should be able
to get an idea of the hardware around.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

rnielsen@hns.com wrote:
: I tried the qnx_osinfo command and there are some of the values that are a bit unclear for me.

: We are running QNX 4.25 on a AMD K6/500MHz with 128MB of RAM

: Here are the values from the qnx_osinfo command
: cpu_speed = 12758
: cpu = 586
: totmemk = 65152
: freememk = 52564
: version = 425

: The CPU type, and OS version is correct, but the other values memory and cpu speed are a bit off… am I missing something ?

The structure changed a bit (I think totmemk and freememk weren’t big
enough). Use totpmem and freepmem instead (they’re both long unsigned).
Someone else might know about the CPU speed.


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems

: Here are the values from the qnx_osinfo command
: cpu_speed = 12758
: cpu = 586
: totmemk = 65152
: freememk = 52564
: version = 425

: The CPU type, and OS version is correct, but the other values memory and cpu speed are a bit off… am I missing something ?

The structure changed a bit (I think totmemk and freememk weren’t big
enough). Use totpmem and freepmem instead (they’re both long unsigned).
Someone else might know about the CPU speed.

The totpmem and freepmem worked fine, but the CPU speed is still a mystery. The Watcom Library Reference say “a PC is 96” and the /sys/osinfo.h says “a PC is 960” which one is it ?
and more importent, what does this number mean ?

Is there a way to calculate the CPU speed from other system variables ?.. anyone ?

/Rene Nielsen

rnielsen@hns.com wrote:

: Here are the values from the qnx_osinfo command
: cpu_speed = 12758
: cpu = 586
: totmemk = 65152
: freememk = 52564
: version = 425

: The CPU type, and OS version is correct, but the other values memory and cpu speed are a bit off… am I missing something ?

The structure changed a bit (I think totmemk and freememk weren’t big
enough). Use totpmem and freepmem instead (they’re both long unsigned).
Someone else might know about the CPU speed.

The totpmem and freepmem worked fine, but the CPU speed is still a mystery. The Watcom Library Reference say “a PC is 96” and the /sys/osinfo.h says “a PC is 960” which one is it ?
and more importent, what does this number mean ?

Is there a way to calculate the CPU speed from other system variables ?.. anyone ?

The CPU speed is hosed anyway with “modern” CPUs. The CPU speed number is the same as
that produced by “sin ne”, where it sez, “Speed”, i.e.,

Nid Machine Cpu Fpu Speed Memory Hard Flop Other Display Flags
1 PCI 686 687 19117 402.1M 240121M 1.4M TCP VGA Color -3+±—8P
2 PCI 686 687 58702 536.3M 35673M 1.4M cd VGA Color -3+±—8P
6 PCI 686 687 59397 268.0M 8257M 1.4M cd VGA Color -3+±—8P


137216 1206M 284051M

Machine 1 is a Pentium 750 MHz, node 2 is an Athlon 1.3GHz and node 6 is a 500 MHz
Pentium. As you can see, some “roll over” has occurred over the years… :slight_smile:

What do you want to do with the CPU speed, anyway? You might consider writing your
own “benchmark” program that runs at a super-high priority during startup and saves
its “computed CPU performance index” number somewhere for easy reference…

Cheers,
-RK


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.

What do you want to do with the CPU speed, anyway? You might consider writing your
own “benchmark” program that runs at a super-high priority during startup and saves
its “computed CPU performance index” number somewhere for easy reference…

No - We have multiple communication servers running all over the US on different hardware, and we would like to be able to see all the hardware components on the server thru a web interface. We have most
of the information wee need by now, but the cpu speed would be nice to match the number one can read from the bios.

Is it possible to read directly from the BIOS ?

/Rene Nielsen

There is some information that you can read directly from a Pentium processor.
I don’t think it will tell you want you want to know. I doubt there is any
kind of BIOS standard that you could take advantage of, although if all your
hardware is the same, something might be possible. Here is an almost sure
fire method. Run a short program that does something like this.

\

  1. Turn off interrupts
  2. Wait for the system clock to turn over.
  3. Read the Pentium cycle timer
  4. Wait for the system clock to turn over again.
  5. Read the Pentium cycle timer again
  6. Turn on interrupts

Now, do a 64 bit subtraction on the cycle timers and you have a fairly
accurate way to gauge cpu speed.

Previously, rnielsen@hns.com wrote in comp.os.qnx:

What do you want to do with the CPU speed, anyway? You might consider writing your
own “benchmark” program that runs at a super-high priority during startup and saves
its “computed CPU performance index” number somewhere for easy reference…


No - We have multiple communication servers running all over the US on different hardware, and we would like to be able to see all the hardware components on the server thru a web interface. We have most
of the information wee need by now, but the cpu speed would be nice to match the number one can read from the bios.

Is it possible to read directly from the BIOS ?

/Rene Nielsen
\


Mitchell Schoenbrun --------- maschoen@pobox.com

rnielsen@hns.com wrote:

For an application, I need to read the system hardware that
the OS (QNX 4.25) is running on. More specificaly I would like
to be to read the CPU type, clock speed, amount of RAM, HD type

In QNX 4.25, the actual MHz of the CPU is recorded in the osinfo
structure, although this is not documented and the field that you
will find it in is not obvious. The following program will report
the proper CPU speed for you.

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

main()
{
struct _osinfo osi;

if( -1 != qnx_osinfo( 0, &osi ) ) {
printf(“CPU speed is %d [%d MHZ %d]\n”, osi.cpu_speed,
osi.cpu_features & 0x00000fff,
osi.cpu );
}
exit( EXIT_SUCCESS );
}


Hope that helps,
Cheers,
Camz.