diff --git a/sched/semaphore/sem_tickwait.c b/sched/semaphore/sem_tickwait.c index c6d4217395..9f219bc571 100644 --- a/sched/semaphore/sem_tickwait.c +++ b/sched/semaphore/sem_tickwait.c @@ -100,8 +100,9 @@ int nxsem_tickwait(FAR sem_t *sem, uint32_t delay) if (delay == 0) { - /* Return the errno from nxsem_trywait() */ + /* Timed out already before waiting */ + ret = -ETIMEDOUT; goto out; } @@ -149,7 +150,7 @@ out: int nxsem_tickwait_uninterruptible(FAR sem_t *sem, uint32_t delay) { - clock_t end = clock_systime_ticks() + delay; + clock_t end = clock_systime_ticks() + delay + 1; int ret; for (; ; )