diff --git a/sched/semaphore/sem_tickwait.c b/sched/semaphore/sem_tickwait.c index 9f219bc571..afd4aef9d4 100644 --- a/sched/semaphore/sem_tickwait.c +++ b/sched/semaphore/sem_tickwait.c @@ -68,12 +68,10 @@ int nxsem_tickwait(FAR sem_t *sem, uint32_t delay) { - FAR struct tcb_s *rtcb = this_task(); + FAR struct tcb_s *rtcb; irqstate_t flags; int ret; - DEBUGASSERT(sem != NULL && up_interrupt_context() == false); - /* We will disable interrupts until we have completed the semaphore * wait. We need to do this (as opposed to just disabling pre-emption) * because there could be interrupt handlers that are asynchronously @@ -106,6 +104,8 @@ int nxsem_tickwait(FAR sem_t *sem, uint32_t delay) goto out; } + rtcb = this_task(); + /* Start the watchdog with interrupts still disabled */ wd_start(&rtcb->waitdog, delay, nxsem_timeout, (uintptr_t)rtcb);