Is there a standard way for your program to check to see how many cpus are on a host?
I know openbsd has hw.ncpu in the sys variables. On linux is there a better way then to look at /proc/cpuinfo? Is there any standard way to do this on unixes?
thanks mates
standard for checking to see how many cpus are on a host?
Started by
SigFLUP
, Sep 01 2009 09:46 PM
2 replies to this topic
#1
Posted 01 September 2009 - 09:46 PM
#2
Posted 01 September 2009 - 09:53 PM
There is no standard way to determine the number of CPUs on a system. Instead, the manual way is preferred. For example, the make command has a -j switch, to specify the number of jobs. You should leave the number of worker threads up to the user, not the system.
If you really want to though, all you need to do is put all the methods together in a C file (or whatever language you're using) and protect them all with #ifdef preprocessor statements. That way, the right one will magically appear in your source code when you compile it on each platform.
If you really want to though, all you need to do is put all the methods together in a C file (or whatever language you're using) and protect them all with #ifdef preprocessor statements. That way, the right one will magically appear in your source code when you compile it on each platform.
#3
Posted 04 September 2009 - 01:48 PM
Slowlaris has psrinfo
BinRev is hosted by the great people at Lunarpages!











