summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 6e8b53eb1..d1e13c949 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -323,11 +323,29 @@ void Reschedule() {
323 Thread* prev = GetCurrentThread(); 323 Thread* prev = GetCurrentThread();
324 Thread* next = NextThread(); 324 Thread* next = NextThread();
325 if (next > 0) { 325 if (next > 0) {
326 INFO_LOG(KERNEL, "context switch 0x%08X -> 0x%08X", prev->GetHandle(), next->GetHandle());
327
326 SwitchContext(next); 328 SwitchContext(next);
327 329
328 // Hack - automatically change previous thread (which would have been in "wait" state) to 330 // Hack - automatically change previous thread (which would have been in "wait" state) to
329 // "ready" state, so that we can immediately resume to it when new thread yields. FixMe to 331 // "ready" state, so that we can immediately resume to it when new thread yields. FixMe to
330 // actually wait for whatever event it is supposed to be waiting on. 332 // actually wait for whatever event it is supposed to be waiting on.
333
334 ChangeReadyState(prev, true);
335 } else {
336 INFO_LOG(KERNEL, "no ready threads, staying on 0x%08X", prev->GetHandle());
337
338 // Hack - no other threads are available, so decrement current PC to the last instruction,
339 // and then resume current thread. This should always be called on a blocking instruction
340 // (e.g. svcWaitSynchronization), and the result should be that the instruction is repeated
341 // until it no longer blocks.
342
343 // TODO(bunnei): A better solution: Have the CPU switch to an idle thread
344
345 ThreadContext ctx;
346 SaveContext(ctx);
347 ctx.pc -= 4;
348 LoadContext(ctx);
331 ChangeReadyState(prev, true); 349 ChangeReadyState(prev, true);
332 } 350 }
333} 351}