From 585f86c8056f2b416745456bb32bb67f627d67fc Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 12 Oct 2013 10:54:57 -0700 Subject: [PATCH 1/2] Make sure the io thread doesn't revive itself. Stupid zombies. Stay dead. --- Core/HLE/sceIo.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index aa104fd02e..aebf3e7de5 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -435,6 +435,7 @@ void __IoManagerThread() { } void __IoWakeManager() { + ioManagerThreadEnabled = false; ioManager.FinishEventLoop(); ioManager.SyncThread(); } From a79b168accc8cd5523b7ddb7691ed425025a7f6f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 12 Oct 2013 10:55:31 -0700 Subject: [PATCH 2/2] Make sure the cpu thread ends on Core_Stop(). Sometimes it didn't, which was just a bit confusing. --- Core/System.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Core/System.cpp b/Core/System.cpp index 125114ecef..76cc0b7fc4 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -95,23 +95,31 @@ bool IsOnSeparateCPUThread() { } } +void CPU_SetState(CPUThreadState to) { + lock_guard guard(cpuThreadLock); + cpuThreadState = to; + cpuThreadCond.notify_one(); + cpuThreadReplyCond.notify_one(); +} + bool CPU_NextState(CPUThreadState from, CPUThreadState to) { lock_guard guard(cpuThreadLock); if (cpuThreadState == from) { - cpuThreadState = to; - cpuThreadCond.notify_one(); - cpuThreadReplyCond.notify_one(); + CPU_SetState(to); return true; } else { return false; } } -void CPU_SetState(CPUThreadState to) { +bool CPU_NextStateNot(CPUThreadState from, CPUThreadState to) { lock_guard guard(cpuThreadLock); - cpuThreadState = to; - cpuThreadCond.notify_one(); - cpuThreadReplyCond.notify_one(); + if (cpuThreadState != from) { + CPU_SetState(to); + return true; + } else { + return false; + } } bool CPU_IsReady() { @@ -261,8 +269,13 @@ void Core_UpdateState(CoreState newState) { } void System_Wake() { + if (CPU_IsReady()) { + CPU_NextStateNot(CPU_THREAD_NOT_RUNNING, CPU_THREAD_SHUTDOWN); + CPU_WaitStatus(cpuThreadReplyCond, &CPU_IsShutdown); + } if (gpu) { gpu->FinishEventLoop(); + gpu->SyncThread(); } } @@ -302,7 +315,7 @@ void PSP_Shutdown() { Core_UpdateState(CORE_ERROR); Core_NotifyShutdown(); if (cpuThread != NULL) { - CPU_SetState(CPU_THREAD_SHUTDOWN); + CPU_NextStateNot(CPU_THREAD_NOT_RUNNING, CPU_THREAD_SHUTDOWN); CPU_WaitStatus(cpuThreadReplyCond, &CPU_IsShutdown); delete cpuThread; cpuThread = 0;