Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

detect number of CPU's

12 views
Skip to first unread message

gordy

unread,
Feb 17, 2001, 12:47:15 AM2/17/01
to
does anyone know a way to detect the number of cpus? from cpuid I can only
see if the cpu supports smp.. I guess the number of cpus would be provided
by the OS or BIOS? is there a way to get this number in windows?
thanks,
gordy

Radek Zajic

unread,
Feb 17, 2001, 12:43:04 PM2/17/01
to
> by the OS or BIOS? is there a way to get this number in windows?

I've just found the Windows API function to determine number of processors.
It's GetSystemInfo. Look at it in Windows API functions reference.

Regards,
Radek

Radek Zajic

unread,
Feb 17, 2001, 12:47:46 PM2/17/01
to
> does anyone know a way to detect the number of cpus? from cpuid I can only

I think there's some info about SMP in Ralf Brown's Interrupt List - APIC is
the way how to determine it.

> see if the cpu supports smp.. I guess the number of cpus would be provided
> by the OS or BIOS? is there a way to get this number in windows?

In Windows 9x/ME there isn't an easy way how to determine the number of
CPUs. Win9x/ME supports only one CPU, so on a SMP system the alternate CPUs
stay unused. Windows NT/2000/XP(=Whistler) supports more CPUs (Except the
WinXP Personal version which will support only one CPU). There are some API
functions that return the number of CPUs, but that number is always limited
by the version of Windows you use (e.g. 9x/ME/XP Personal returns one CPU,
nt/2000/xp returns at most 2 CPUs, NT server returns at most 4 CPUs (not
sure here?), 2000/XP server returns at most 4 CPUs, 2000/XP advanced server
returns at most 8 CPUs and 2000/XP datacenter server returns at most 32
CPUs)

I hope this helps...

Regards,
Radek


Jon Kirwan

unread,
Feb 17, 2001, 4:15:55 PM2/17/01
to
On Sat, 17 Feb 2001 11:47:46 CST, "Radek Zajic" <rza...@seznam.cz>
wrote:

>> does anyone know a way to detect the number of cpus? from cpuid I can only
>
>I think there's some info about SMP in Ralf Brown's Interrupt List - APIC is
>the way how to determine it.

You can also use the multiprocessor specification from Intel (the
latest I have a copy of, is version 1.4, May 1997.) The BIOS is
permitted to place this table in one of several areas in memory, but
you can use it to find out about the CPUs in the system, their
features, and the buses on the system.

The MP configuration table can be at:

a. In the first kilobyte of Extended BIOS Data Area (EBDA), or
b. Within the last kilobyte of system base memory if the EBDA
segment is undefined, or
c. At the top of system physical memory, or
d. In the BIOS read-only memory space between 0E0000h and 0FFFFFh.

[The BIOS reports the base memory size in a two-byte location (40:13h)
of the BIOS data area. The base memory size is reported in kilobytes
minus 1K, which is used by the EBDA segment or for other purposes.
The exact starting address of the EBDA segment for EISA or MCA systems
can be found in a two-byte location (40:0Eh) of the BIOS data area.]

If system memory is used, the BIOS must not report this memory as part
of the available memory space. The two MP configuration data
structures can be located in the ROM space only if the system is
not dynamically reconfigurable.

You need a small search algorithm to find it on a wide variety of
systems.

Jon

Rick C. Hodgin

unread,
Feb 17, 2001, 9:26:15 PM2/17/01
to
>I've just found the Windows API function to determine number of processors.
>It's GetSystemInfo. Look at it in Windows API functions reference.

There's a much easier way. Look for the environment variable called
"NUMBER_OF_PROCESSORS". This works under any application that's able
to query the environment, including a DOS program.

- Rick C. Hodgin

Radek Zajic

unread,
Feb 18, 2001, 7:21:07 PM2/18/01
to
> >It's GetSystemInfo. Look at it in Windows API functions reference.
> There's a much easier way. Look for the environment variable called
> "NUMBER_OF_PROCESSORS". This works under any application that's able
> to query the environment, including a DOS program.

Yes, that's true, but only in NT :-) sure, 9x series cannot use more than
one cpu, but... :-)

Regards,
Radek


Bob Smith

unread,
Feb 22, 2001, 10:30:51 PM2/22/01
to
Another way is to use the DMI/SMBIOS specification and count the number
of Type 4 (Processor Information) records present. On a multiprocessor
system I have, the first record's socket designation is marked as
Primary Processor, and the second record says Secondary Processor.

There's a program SMBIOS (with source code) on my website to display
this information:

http://www.sudleyplace.com/download.htm

Running SMBIOS /t=4 on my multiprocessor system displays

--> Type 4: Processor Information
Struc length is 26 bytes.
Struc handle is 0004h.
Socket Designation: Primary Processor
Processor Type: Central Processor
Processor Family: Pentium II processor
Processor Manufacturer: Intel Corporation
Processor ID: 00000652h.
Features: ...
Processor Version: Intel(R) Pentium(R) II processor
Voltage: 2.9V
External Clock (MHz): 100.
Max Speed (MHz): 450.
Current Speed (MHz): 450.
Status: CPU Socket: Populated
CPU Status: CPU Enabled
Processor Upgrade: Slot 1

--> Type 4: Processor Information
Struc length is 26 bytes.
Struc handle is 0005h.
Socket Designation: Secondary Processor
Processor Type: Central Processor
Processor Family: Pentium II processor
Processor Manufacturer: Intel Corporation
Processor ID: 00000652h.
Features: ...
Processor Version: Intel(R) Pentium(R) II processor
Voltage: 2.9V
External Clock (MHz): 100.
Max Speed (MHz): 450.
Current Speed (MHz): 450.
Status: CPU Socket: Populated
CPU Status: CPU Enabled
Processor Upgrade: Slot 1

_________________________________________
Bob Smith -- bsm...@sudleyplacedespam.com
a.k.a. bsm...@qualitasdespam.com

I've been getting a lot of junk e-mail lately,
so to reply to me directly, delete "despam".

0 new messages