title: Why disabling interrupts achieves mutual exclusion in uni-processor systems?
body: <p>Section 28.5 of <a href="http://pages.cs.wisc.edu/~remzi/OSTEP/threads-locks.pdf" rel="nofollow noreferrer">the Locks Chapter</a> of the OSTEP book shows that disabling interrupts achieves mutual exclusion among threads in uni-processor systems. I don't get it: what if the thread holding the lock calls some system calls in the critical section? In this case, it relinquishes CPU before releasing the lock and thus another thread waiting for the lock may enter the critical section as well. I went through the section but couldn't find an answer.</p>
  
  <p>According to the Slide 2 of another <a href="https://homes.cs.washington.edu/~arvind/cs422/lectureNotes/l6-6.pdf" rel="nofollow noreferrer">lecture notes</a>, <code>Internal events are thread does something to relinquish the CPU</code> and <code>Preventing internal events is easy</code>. Then Slide 3 explains the same locking implementation by disabling interrupts as the one in the OSTEP book. </p>
  
  <p>Although I'm sort of confirmed that it is indeed necessary to consider the case where the thread holding the lock relinquishes CPU by itself, I still have two questions:</p>
  
  <ol>
  <li>why does the implementation in both of the above references consider disabling interrupts only while ignoring the internal events handling?</li>
  <li>why are internal events easy to prevent? How to achieve it? The only solution I came up with was to prevent the thread from calling any system calls in the critical section, which is too restrictive in my opinion. </li>
  </ol>
  
  <p>Can anyone share wisdom with me? </p>