From fa228ca637b84e6441879769d54a531ab6aba113 Mon Sep 17 00:00:00 2001
From: Subv <subv2112@gmail.com>
Date: Mon, 21 Aug 2017 20:54:29 -0500
Subject: [PATCH] Kernel/Threads: Don't immediately switch to the new main
 thread when loading a new process.

This is necessary for loading multiple processes at the same time.
The main thread will be automatically scheduled when necessary once the scheduler runs.
---
 src/core/hle/kernel/thread.cpp | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index f5f2eb2f7f..b957c45dd4 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -478,8 +478,6 @@ void Thread::BoostPriority(s32 priority) {
 }
 
 SharedPtr<Thread> SetupMainThread(u32 entry_point, s32 priority) {
-    DEBUG_ASSERT(!GetCurrentThread());
-
     // Initialize new "main" thread
     auto thread_res = Thread::Create("main", entry_point, priority, 0, THREADPROCESSORID_0,
                                      Memory::HEAP_VADDR_END);
@@ -489,9 +487,7 @@ SharedPtr<Thread> SetupMainThread(u32 entry_point, s32 priority) {
     thread->context.fpscr =
         FPSCR_DEFAULT_NAN | FPSCR_FLUSH_TO_ZERO | FPSCR_ROUND_TOZERO | FPSCR_IXC; // 0x03C00010
 
-    // Run new "main" thread
-    SwitchContext(thread.get());
-
+    // Note: The newly created thread will be run when the scheduler fires.
     return thread;
 }
 
-- 
GitLab