Community
cancel
Showing results for 
Search instead for 
Did you mean: 
aliceander
Beginner
49 Views

linux C prg to test cpu (32 vs 64)

I have Redhat 4.4 running on a roomful of machines with Xeon processors. I want to write a program to prove they are 32 or 64 bit CPUs, but I'm stumped. Is there a C program to test if a CPU is 32bt or 64bt even if it's running in a 32bit OS?

0 Kudos
2 Replies
aliceander
Beginner
49 Views

/proc/cpuinfo provides a lot of good information -- if it doesn't say anything about a 64 bit CPU in that file, e.g. x64, does that mean I have a 32 bit processor? I thought the Xeon CPU was 64 bit, but I cannot prove that, one way or another yet.

cephexin
Beginner
49 Views

Well, if you want to write your own program, you can use "cpuid" opcode, and there are some factors you should care of in that way:

1. Processor Type
2. Vendor ID
3. Model Name
4. Speed (CPU MegaHertz field)

So you run up CPUID opcode verify the "Processor Type", then you should check for "Vendor ID", vendor id is the place where you can decide on what branch your processor is product, for example GeniueIntel, etc. Afterward you can check for the Model name and Speed.
With these 4 factors known, you can ALMOST (not for sure) turn to the right answer on your processor's details.

btw, there's a more advanced program named "CPU-Z", done the same with most details on the scene. You can seek it here: http://www.cpuid.com/cpuz.php

Aside, the "cpuinfo" program uses the CPUID opcode tho. Let's run out a sample:

-------------------------------------------------
c3ph@kidon:~$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel Celeron CPU 2.40GHz
stepping : 1
cpu MHz : 2405.729
cache size : 256 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe constant_tsc up pni monitor ds_cpl cid xtpr
bogomips : 4814.59

c3ph@kidon:~$
-------------------------------------------------

You see, this is Geniue, Intel, Celeron => it's more appropriately a box with a single Intel 32-Bit processor at 2.40Ghz speed.
btw, let's run out another sample:

-------------------------------------------------
c3ph@kamemiut:~$ cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 15
model : 35
model name : Dual Core AMD Opteron Processor 175
stepping : 2
cache size : 1024 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall mmxext lm 3dnowext 3dnow pni
bogomips : 2188.90

processor : 1
vendor_id : AuthenticAMD
cpu family : 15
model : 35
model name : Dual Core AMD Opteron Processor 175
stepping : 2
cache size : 1024 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall mmxext lm 3dnowext 3dnow pni
bogomips : 2188.90

c3ph@kamemiut:~$
-------------------------------------------------

You see, this is AuthenticAMD, Dual AMD , Opteron => This is almost a Dual Core box with AMD processors, both of 'em with 64-bit technology.

And let's see our last example:

-------------------------------------------------
processor : 0
vendor_id : GenuineIntel
type : primary processor
cpu family : 6
model : 15
model name : Intel Xeon CPU 3060 @ 2.40GHz
stepping : 6
brand id : 0
cpu count : 2
apic id : 0
cpu MHz : 2400
fpu : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clfl dtes acpi mmx fxsr sse sse2 ss htt tmi pbe pni monitor ds_cpl tm2 est

-------------------------------------------------

You see, this is Geniue, Intel, Xeon 3060 (at 2.40) => so this is almost a Multi Core box with Intel Xeon Processors, both with 32-Bit technology. Anyway, in any case, you can verify the "model number" in the documentations to know the processor's details too.

BTW, as i told ya above, the "CPUINFO" program uses the CPUID o pcode too, so to gain more handy results, you would try the opcode yourself...

Of course, there's another way to know the CPU's details which is dealing with the Flags, which i'm gonna explain it here, if you're interested to know it tho.

Questions!? come on...
Reply