Jump to content


Photo
- - - - -

standard for checking to see how many cpus are on a host?


  • Please log in to reply
2 replies to this topic

#1 SigFLUP

SigFLUP

    SUPR3M3 31337 Mack Daddy P1MP

  • Members
  • 367 posts
  • Gender:Not Telling

Posted 01 September 2009 - 09:46 PM

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

#2 Ohm

Ohm

    I could have written a book with all of these posts

  • Members
  • 3,209 posts
  • Gender:Male
  • Location:Maine, USA

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.

#3 duper

duper

    Dangerous free thinker

  • Members
  • 816 posts
  • Location:NYC

Posted 04 September 2009 - 01:48 PM

Slowlaris has psrinfo




BinRev is hosted by the great people at Lunarpages!