title: How are multiple CPU cores used by the OS
body: <p>There are a lot of articles that discuss multi-core myth. That, in order to really benefit from multiple cores, one needs to write parallel algorithms. Many of them mention <a href="http://en.wikipedia.org/wiki/Amdahl&#39;s_law" rel="nofollow">Amdahl's law</a>.</p>
  
  <p>Lets assume for simplicity that we have a desktop computer with a 4-core commodity CPU. And assume that the goal is to improve our application performance, as well as overall system performance.</p>
  
  <p>I wonder how CPU cores are used to perform tasks.</p>
  
  <ul>
  <li>Whether threads from a single process are allocated all cores</li>
  <li>Or threads from different processes are scheduled to run on different cores.</li>
  </ul>
  
  <p>If the latter is the case, then why is the myth even discussed? Won't multitasking OSes always benefit from multi-core CPUs, even if all the processes are single threaded? Are threads from the same process more likely to be scheduled at the same time on multiple cores?</p>
  
  <ul>
  <li>What are some factors that matter? CPU cache maybe? Some application related maybe? Why?</li>
  <li>Why would you ever want to use parallel libraries/algorithms? After all, CPU resources are shared between all running processes and there are always enough of them.</li>
  </ul>
  
  <p>Is there an "active process" notion? i.e. process that gets most attention from the scheduler. If so, then how much more attention does this process usually get?</p>