Sign in to follow this  

Num Processors Linux

This topic is 3712 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Sign in to follow this