title: What is the difference between nonpreemptive and preemptive kernels, when switching to user mode?
body: <p>I'm reading "Understanding the Linux Kernel, 3rd Edition", and in Chapter 5, Section "Kernel Preemption", it says:</p>
  
  <blockquote>
    <p>All process switches are performed by the <code>switch_to</code> macro. In both preemptive
    and nonpreemptive kernels, a process switch occurs when a process has finished
    some thread of kernel activity and the scheduler is invoked. However, in nonpreemptive kernels, the current process cannot be replaced unless it is about to <strong>switch
    to User Mode</strong>.</p>
  </blockquote>
  
  <p>I still don't see the difference here between non-preemptive and preemptive kernels, because any way you need to wait for the current process to switch to user mode.</p>
  
  <p>Say there is a process <em>p</em> running in kernel mode, and whose time quantum expires, then the <code>scheduler_tick()</code> is called, and it sets the <code>NEED_RESCHED</code> flag of <em>p</em>.
  But <code>schedule()</code> is invoked only when <em>p</em> switch to user mode (right?).</p>
  
  <p>So what if <em>p</em> never switches to user mode?</p>
  
  <p>And if it switched to user mode but it takes a "long" time between the moment <code>scheduler_tick()</code> set <code>NEED_RESCHED</code> and the moment <em>p</em> actually switched to user mode - then it used more than its quantum?</p>