diff --git a/src/system/kernel/sem.cpp b/src/system/kernel/sem.cpp index 4466446a0a..e93e05fff0 100644 --- a/src/system/kernel/sem.cpp +++ b/src/system/kernel/sem.cpp @@ -938,8 +938,10 @@ switch_sem_etc(sem_id semToBeReleased, sem_id id, int32 count, B_INTERRUPTED, true); } RELEASE_SEM_LOCK(sSems[slot]); - while ((thread = thread_dequeue(&wakeupQueue)) != NULL) - scheduler_enqueue_in_run_queue(thread); + + struct thread *wakeupThread; + while ((wakeupThread = thread_dequeue(&wakeupQueue)) != NULL) + scheduler_enqueue_in_run_queue(wakeupThread); // fall through and reschedule since another thread with a higher priority may have been woken up }