title: Why disabling interrupts disables kernel preemption and how spin lock disables preemption
body: <p>I am reading <em>Linux Kernel Development</em> recently, and I have a few questions related to disabling preemption.</p>
  
  <ol>
  <li><p>In the "Interrupt Control" section of chapter 7, it says:</p>
  
  <blockquote>
    <p>Moreover, disabling interrupts also disables kernel preemption.</p>
  </blockquote>
  
  <p>I also read from the book that kernel preemption can occur in the follow cases:</p>
  
  <blockquote>
    <p>When an interrupt handler exits, before returning to kernel-space.<br>
    When kernel code becomes preemptible again.<br>
    If a task in the kernel explicitly calls schedule()<br>
    If a task in ther kernel blocks (which results in a call to schedule())</p>
  </blockquote>
  
  <p>But I can't relate disabling interrupts with these cases.</p></li>
  <li><p>As far as I know, a spinlock would disable preemption with the <strong>preempt_disable()</strong> function. </p>
  
  <p>The post <a href="https://stackoverflow.com/questions/1957398/what-exactly-are-spin-locks">What exactly are &quot;spin-locks&quot;?</a>
  says:</p>
  
  <blockquote>
    <p>On a single core machine a spinlock is simply a "disable interrupts" or "raise IRQL" which prevents thread scheduling completely.</p>
  </blockquote>
  
  <p>Does <strong>preempt_disable()</strong> disable preemption by disabling interrupts?</p></li>
  </ol>