Num Processors Linux

Started by
1 comment, last by Wolfdog 16 years, 6 months ago
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?
Advertisement
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.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
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.

This topic is closed to new replies.

Advertisement