Skip to content

Commit a6b2b03

Browse files
committed
core/cond.c: cond_wait() expect enabled interrupts
1 parent 5c06502 commit a6b2b03

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

core/cond.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ void cond_init(cond_t *cond)
3434

3535
void cond_wait(cond_t *cond, mutex_t *mutex)
3636
{
37-
unsigned irqstate = irq_disable();
37+
assert(irq_is_enabled());
38+
irq_disable();
3839
thread_t *me = thread_get_active();
3940

40-
mutex_unlock(mutex);
4141
sched_set_status(me, STATUS_COND_BLOCKED);
4242
thread_add_to_list(&cond->queue, me);
43-
irq_restore(irqstate);
43+
irq_enable();
44+
/* mutex_unlock() might reschedule, so it needs to be called with interrupts
45+
* enabled. */
46+
mutex_unlock(mutex);
4447
thread_yield_higher();
45-
46-
/*
47-
* Once we reach this point, the condition variable was signalled,
48-
* and we are free to continue.
49-
*/
48+
/* Once we reach this point, the condition variable was signaled, and we are
49+
* free to continue. */
5050
mutex_lock(mutex);
5151
}
5252

0 commit comments

Comments
 (0)