From 2a9c6407390d79c01d5036fdfeb7979fb3aee95b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 31 Mar 2013 09:45:41 -0700 Subject: [PATCH 1/2] When starting a thread, put old thread at end. This matters so the right thread is run later when scheduling switches back. --- Core/HLE/sceKernelThread.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index 38c7e691e8..16f1256294 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -1614,7 +1614,9 @@ int sceKernelStartThread(SceUID threadToStartID, u32 argSize, u32 argBlockPtr) // TODO: Maybe this happens even for worse-priority started threads? dispatchEnabled = true; - __KernelChangeReadyState(currentThread, true); + if (cur && cur->isRunning()) + cur->nt.status &= ~THREADSTATUS_RUNNING; + __KernelChangeReadyState(cur, currentThread, true); hleReSchedule("thread started"); } else if (!dispatchEnabled) From 72921e0a3c4cde3fdf86e312968f8d184b8f60ed Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 31 Mar 2013 12:09:59 -0700 Subject: [PATCH 2/2] If the mipscall id doesn't match, don't create. Fixes a crash when savestating. --- Core/HLE/sceKernelThread.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index 16f1256294..c09fe8aa3a 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -163,7 +163,10 @@ public: return id; } MipsCall *get(u32 id) { - return calls_[id]; + auto iter = calls_.find(id); + if (iter == calls_.end()) + return NULL; + return iter->second; } MipsCall *pop(u32 id) { MipsCall *temp = calls_[id];