forked from Archive/PX4-Autopilot
Added timed wait semaphore
This commit is contained in:
parent
fb24a54ca4
commit
e2894c4a46
|
@ -75,6 +75,20 @@ int px4_sem_wait(px4_sem_t *s)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int px4_sem_timedwait(px4_sem_t * s, const struct timespec * abstime)
|
||||
{
|
||||
pthread_mutex_lock(&(s->lock));
|
||||
s->value--;
|
||||
|
||||
if (s->value < 0) {
|
||||
pthread_cond_timedwait(&(s->wait), &(s->lock), abstime);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&(s->lock));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int px4_sem_post(px4_sem_t *s)
|
||||
{
|
||||
pthread_mutex_lock(&(s->lock));
|
||||
|
|
Loading…
Reference in New Issue