title: POSIX Semaphores on Mac OS X: sem_timedwait alternative
body: <p>I am trying to port a project (from linux) that uses Semaphores to Mac OS X however some of the posix semaphores are not implemented on Mac OS X</p>
  
  <p>The one that I hit in this port is <code>sem_timedwait()</code></p>
  
  <p>I don't know much about semaphores but from the man pages <code>sem_wait()</code> seems to be close to <code>sem_timedwait</code> and it is implemented</p>
  
  <p>From the man pages</p>
  
  <blockquote>
    <p><code>sem_timedwait()</code>  function  shall
    lock the semaphore referenced by<br>
    <code>sem</code> as in the <code>sem_wait()</code> function.
    However, if the semaphore cannot be<br>
    locked  without  waiting  for  another
    process or thread to unlock the<br>
    semaphore by performing a <code>sem_post()</code>
    function, this wait shall be ter-<br>
    minated when the specified timeout
    expires</p>
  </blockquote>
  
  <p>From my limited understanding of how semphores work I can see that <code>sem_timedwait()</code> is safer, but I still should be able to use sem_wait()</p>
  
  <p>Is this correct? If not what other alternatives do I have...</p>
  
  <p>Thanks</p>