Reschedule: Handle the case when next->status == THREADSTATUS_READY

This commit is contained in:
MerryMage 2016-05-28 21:37:07 +01:00
parent e33f17b046
commit 63b0687242

View File

@ -564,8 +564,16 @@ void Reschedule() {
HLE::DoneRescheduling();
// Don't bother switching to the same thread
if (next == cur)
if (next == cur) {
if (next) {
// The status can be THREADSTATUS_READY and not THREADSTATUS_RUNNING as one would expect.
// This occurs in the case when an object the thread is waiting on immediately wakes up
// the current thread before Reschedule() is called.
ASSERT(next->status == THREADSTATUS_RUNNING || next->status == THREADSTATUS_READY);
next->status = THREADSTATUS_RUNNING;
}
return;
}
if (cur && next) {
LOG_TRACE(Kernel, "context switch %u -> %u", cur->GetObjectId(), next->GetObjectId());