From 63b06872422766db335a5c0f789a18f2ca020285 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sat, 28 May 2016 21:37:07 +0100 Subject: [PATCH] Reschedule: Handle the case when next->status == THREADSTATUS_READY --- src/core/hle/kernel/thread.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 16c807d20..fa9e7b2ef 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -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());