title: How to initialise a binary semaphore in C
body: <p>In the <a href="http://linux.die.net/man/3/sem_init" rel="noreferrer">man page</a> it appears that even if you initialise a semaphore to a value of one:</p>
  
  <pre><code>sem_init(&amp;mySem, 0, 1);
  </code></pre>
  
  <p>It could still be incremented to a value greater than 1 with multiple calls to</p>
  
  <pre><code>sem_post(&amp;mySem);
  </code></pre>
  
  <p>But in this <a href="http://www.amparo.net/ce155/sem-ex.html" rel="noreferrer">code example</a> the comment seems to think differently:</p>
  
  <pre><code>sem_init(&amp;mutex, 0, 1);      /* initialize mutex to 1 - binary semaphore */
  </code></pre>
  
  <p>Is it possible to initialise a strictly binary semaphore in C?</p>
  
  <p><em>Note: The reason for doing this instead of using a mutex in this case is the sem_post and sem_wait may be called by different threads.</em></p>