title: How to use sched_getaffinity and sched_setaffinity in Linux from C?
body: <p>I am trying to:</p>
  
  <ul>
  <li><p>Run 16 copies concurrently with processor pinning (2 copies per core)</p></li>
  <li><p>Run 8 copies concurrently with processor pinning (2 copies per core) and flipping processor core to the furthest core after certain function say function 1 finishes.</p></li>
  </ul>
  
  <p>The problem I am facing is how to select the farthest processor.</p>
  
  <p>Some friends suggested to use sched_getaffinity and sched_setaffinity but I count not find any good examples.</p>