[erlang-questions] logical_processors_available unknown on mac

Alin Popa <>
Fri Feb 19 00:42:04 CET 2016


Yeah, I know there are some sysctl OSX flags that can be looked up, the
thing that I don't know if those are the same as those used on the Linux
(or other?) implementations.

Alin

On Thu, Feb 18, 2016 at 10:54 PM, Richard A. O'Keefe <>
wrote:

>
>
> On 19/02/16 12:46 am, Alin Popa wrote:
>
>> On Wed, Feb 17, 2016 at 1:25 PM, Alin Popa < <mailto:
>> >> wrote:
>>
>>         I was recently trying to use
>>         `erlang:system_info(logical_processors_available).` on my mac,
>>         and getting `unknown` atom back; anyone has any idea if this
>>         is really by design?
>>
>>
>  | head
> % sysctl -a | grep cpu | head
> hw.ncpu = 4
> hw.cpufrequency = 3200000000
> to= 4
> hw.ncpu: 4
> hw.activecpu: 4
> hw.physicalcpu: 4
> hw.physicalcpu_max: 4
> hw.logicalcpu: 4
> hw.logicalcpu_max: 4
> hw.cputype: 7
>
> You can get at this with, e.g.,
>     int ans; size_t anslen = sizeof ans;
>     sysctlbyname("hw.activecpu", &ans, &anslen, 0, 0)
> For that matter,
>     sysconf(_SC_NPROCESSORS_ONLN)
> and
>     sysconf(_SC_NPROCESSORS_CONF)
> are supported.
>
>
>  *   hw.activecpu              - The number of processors currently
> available for executing threads.
>  *                               Use this number to determine the number
> threads to create in SMP aware applications.
>  *                               This number can change when power
> management modes are changed.
>
> There are so many ways to count the number of CPUs on a Mac.
> I suspect that hw.activecpu is the one to use; if it isn't, then
> hw.logicalcpu may be the one.
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160218/f79cedb4/attachment.html>


More information about the erlang-questions mailing list