title: How is context switching of threads done on a multi-core processor?
body: <p>When doing context switching on a single-core processor, the code responsible is executed on the only CPU which takes care of switching the threads.</p>
  
  <p>But how is this done when we have multiple CPUs? Is there a master CPU which does all the context switching of all slave CPUs? Is each CPU responsible for its own context switching? If so, how is the switching synchronized so that two CPUs are not executing the same thread? Or is there some other mechanism in place?</p>