title: Semaphores for process synchronization
body: <p>I have never understood semaphores well enough. Every time, I venture to understand them, something pops up, which I don't understand.</p>
  
  <p>Here is my question at this moment:</p>
  
  <p>I read in "Operating System Concepts" that: <strong>"*<em>A semaphore S is an integer variable that, apart from initialization, is accessed only through two standard atomic operations: wait() and signal().</strong>"</em>*</p>
  
  <p>What does atomic mean here? Does it mean that this operation will be executed at one go?</p>
  
  <p>But then the book goes on to give one sample implementation of wait():</p>
  
  <pre><code>wait(S) {
  while S &lt;= 0
  ; // no-op
  S--;
  }
  </code></pre>
  
  <p>With a while loop in it (which depends on other process), how can this ever run at one go (i.e. without any other process executing to signal, which will break the while loop)</p>
  
  <p>Please explain,</p>