Number of active cpus on a Mac...
One nifty feature on most modern macs is that you can disable processors on the fly. Up front, that doesn’t sound like much of a benefit, but in reality it is. As a developer, I can examine the compute time using different processor configurations, and see how well the software scales.
One problem that I ran into is determining the number of available processors. From sysctl’s man page, it shows an entry for ‘hw.ncpu’. However, that’s the number of processors installed on the machine, not the number of active processors. ‘sysctl -a’ turned up the setting I was looking for: ‘hw.availcpu’. Actually, there was another one called ‘hw.activecpu’ that seemed to operate in the same way–it changed when hw.availcpu changed. However sys/sysctl.h recommended using hw.availcpu as the mechanism to determine the number of threads to create for SMP aware applications.
So, for those of you developing SMP aware apps on the Mac, hw.availcpu is the value you need to use.