Number of CPUs

  • Thread starter Thread starter Urs Vogel
  • Start date Start date
U

Urs Vogel

Hi

When measuring the thread pool with ThreadPool.GetMaxThreads(..), it returns
25 threads per CPU. On a hyper threaded machine, though, it returns 50
threads, still only having one CPU. How do I accurately determine the
physical CPU count? Any idea?

Thanks, Urs
 
Urs said:
threads, still only having one CPU. How do I accurately determine the
physical CPU count? Any idea?

I would guess WMI would be the route to take, but more importantly, how
come you need to know the physical CPU-count?

Note that "physical cpu-count" has been a rather vague term for quite a
while now. All recent CPU's have multiple, concurrent computational units.
 
Thanks Helge

I need it for licensing purposes for an application server. Hyper threaded
CPUs must still count as ONE CPU.

Urs
 
Urs Vogel said:
Hi

When measuring the thread pool with ThreadPool.GetMaxThreads(..), it
returns 25 threads per CPU. On a hyper threaded machine, though, it
returns 50 threads, still only having one CPU. How do I accurately
determine the physical CPU count? Any idea?

Thanks, Urs

Read the NUMBER_OF_PROCESSORS environment variable, or use System.Management
and the WMI class Win32_processor.
Note that each core (logical CPU) is treated as a separate CPU by the OS, so
the value returned by GetMaxThreads is valid as far as the CLR is concerned.

Willy.
 
I would not rely on any formula involving the maximum threads per processor
for the simple reason that this value can change with some future build of
the framework. In any case, WMI or some Win32 call surely exists for
determining that. Try Googling on:

"determine number of processors" windows

.... or similar.

--Bob
 
Back
Top