title: Why would there be a problem to get the value of a semaphore and wait()
body: <p>Why would there be a problem to get the value of the semaphore and check it so that when the value of semaphore is > 0, we invoke wait()?
  ie: Why would there be a problem for the following code?</p>
  
  <pre><code>if (getValue(&amp;sem)&gt;0){
      wait(&amp;sem);
  }
  </code></pre>