Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between activeProcessorCount and processorCount?

Tags:

macos

cocoa

The NSProcessInfo class has two methods named processorCount and activeProcessorCount. The documentation is as unhelpful as possible as to what is the different between a processing core and an active processing core. Or, in other words: what counts as an inactive processing core for Cocoa?

like image 281
F'x Avatar asked Aug 31 '11 14:08

F'x


1 Answers

It may be that OS X can shut down cores when the system is overloaded (to reduce temperature).

On older MacBooks, one core could shut down if the power cord was the only power source (no battery). (I can't find link for that one but I'm pretty sure that was the case for my 2007 white MacBook.)

Also, the hwprefs command line utility can enable/disable processors cores.

Most of the time, you really want the activeProcessorCount since it's what really represents the state of the machine.

Edit: hwprefs is gone in Lion, but you can access the same functionality with sysctl -n hw.ncpu

like image 125
gcamp Avatar answered Dec 09 '22 16:12

gcamp