Certainly works on Linux 2.2+, Solaris 8+, Windows 2k, and Windows XP. Probably should work on AIX, Cray, HP-UX, Tru64 Unix, and the rest...
Public Domain. However, if you find it useful, please consider forking out for something on my amazon wishlist
$ cc -o numcpus numcpus.c
$ mv numcpus /wherever/bin/numcpus
If you have a half-decent make implementation you can probably just run:
$ make numcpus
This technique certainly works with GNU make.
Just run it and it will print out as much info as it can get on the processor configuration. This varies a lot from platform to platform.
If you know of a way to detect this information on a platform this code does not work on, or you know how to get extended info on a particular platform, please drop me an email. My address is
pgw99@doc.ic.ac.uk.