title: Why use sysconf(_SC_NPROCESSORS_CONF) to get the number of CPU cores in x264?
body: <p>I find x264 use sysconf(_SC_NPROCESSORS_CONF) instead of sysconf(SC_NPROCESSORS_ONLN) to get the number of CPU cores.</p>
  
  <p>Here is the code snippet in <a href="https://github.com/mirror/x264/blob/master/common/cpu.c" rel="nofollow noreferrer">x264/common/cpu.c</a>:</p>
  
  <pre><code>...
  #ifdef __ANDROID__
      // Android NDK does not expose sched_getaffinity
      return sysconf( _SC_NPROCESSORS_CONF );
  #else
      ...
  ....
  </code></pre>
  
  <p>And I find the difference between _SC_NPROCESSORS_CONF and _SC_NPROCESSORS_ONLN in this <a href="https://www.gnu.org/software/libc/manual/html_node/Processor-Resources.html" rel="nofollow noreferrer">manual</a>:</p>
  
  <blockquote>
    <p>sysconf (_SC_NPROCESSORS_CONF) which returns the number of processors
    the operating system configured. But it might be possible for the
    operating system to disable individual processors and so the call
    sysconf (_SC_NPROCESSORS_ONLN) returns the number of processors which
    are currently online (i.e., available).</p>
  </blockquote>
  
  <p>I have two questions:</p>
  
  <ol>
  <li>What is the difference between "the number of processors the operating system configured" and "the number of processors which are currently online"?</li>
  <li>Why x264 use _SC_NPROCESSORS_CONF in Android to get the number of CPU cores?</li>
  </ol>