title: How does a scheduler regain control when wanted?
body: <p>I'm reading about scheduling, but I can't figure out how a scheduler regains control after it invokes code in the user space.</p>
  
  <p>E.g. the scheduler passes the control to some app in the user space which does some infinite loop and no other hardware interrupt occurs on an one core chip. All documents talk about the scheduler regaining control and preemptivly interrupting the user process, but how does that work if the control is never passed back to the OS?</p>
  
  <p><strong>Question:</strong> Does the scheduler register with some clock in the CPU to be given control again after X msecs? Or is there some other trick? If no, what is the <strong>C function</strong> called to register for regular (or one time?) control regains? </p>