title: Thread Affinity also restrict memory allocation?
body: <p>I am currently working on a NUMA system with two CPUs. The memory access time is not the same for the two CPUs.</p>
  
  <p>I have used <code>PTHREAD_SETAFFINITY_NP</code> to assign threads to specific CPUs:</p>
  
  <pre><code>int stick_this_thread_to_core(int core_id) {
    int num_cores = sysconf(_SC_NPROCESSORS_ONLN);//number of processors
    if (core_id &lt; 0 || core_id &gt;= num_cores)
       return EINVAL;
    cpu_set_t mask;
    CPU_ZERO(&amp;mask);
    CPU_SET(core_id, &amp;mask);
    pthread_t current_thread = pthread_self();    
    return pthread_setaffinity_np(current_thread, sizeof(cpu_set_t), &amp;mask);
  }
  </code></pre>
  
  <p>My question is, does it also restrict the memory allocation of the thread? For example, if I <code>malloc</code> in the thread running in CPU-1, will the memory be allocated in memories of CPU-1 only?</p>