diff --git a/src/platforms/posix/px4_layer/px4_sem.cpp b/src/platforms/posix/px4_layer/px4_sem.cpp index 0aa56a1f3e..184b80a667 100644 --- a/src/platforms/posix/px4_layer/px4_sem.cpp +++ b/src/platforms/posix/px4_layer/px4_sem.cpp @@ -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));