How to correctly use sem_timedwait()
<p>i am trying to get my thread in my program to stop if it can't decrease the semaphore after 10 seconds (another thread could or could not increase it)
I saw that i could use sem_timedwait() for this but i cannot find a good example on the net.
So i just want to replace this:</p>

<pre><code>sem_wait(&amp;full);
//go on with stuff
</code></pre>

<p>with something like this:</p>

<pre><code>sem_timedwait(&amp;full,someTimeStuffThatRepresents10Secs);
if(sem_timedwaitTookLongerThan10){
    pthread.exit(NULL);
}else{
    //do stuff
}
</code></pre>

<p>Any help is appreciated!</p>