Sign in to follow this  
Wolfdog

Num Processors Linux

Recommended Posts

I am using GetSystemInfo in Windows to find the number of physical processors/cores in a machine. Then I am scaling my custom thread pool accordingly. What I am looking for is an equivalent function for Linux, and I would prefer not to use any assembly to do this. Anyone know of a library function for this?

Share this post


Link to post
Share on other sites
Quote:
Original post by Wolfdog
I am using GetSystemInfo in Windows to find the number of physical processors/cores in a machine. Then I am scaling my custom thread pool accordingly. What I am looking for is an equivalent function for Linux, and I would prefer not to use any assembly to do this.

Anyone know of a library function for this?


try reading /proc/cpuinfo

Edit: might not work correctly with intel P4 cpus (HyperThreading seems to make the OS think that there are more physical cpus than there really are)
Ofcourse, treating a HT cpu as 2 cpus doesn't really hurt that much.

Share this post


Link to post
Share on other sites
I think GetSystemInfo has the same problem with HT, but I have prior knowledge of the different types of hardware this will be running on and none have HT. So this is perfect, thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this