diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index 2e9d82b7a8..98bdbe29af 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -605,6 +605,13 @@ bool cpu_thread::check_state() noexcept if (escape) { + if (s_tls_thread_slot == umax) + { + // Restore thread in the suspend list + std::lock_guard lock(g_fxo->get()->cpu_suspend_lock); + s_tls_thread_slot = g_fxo->get()->add(this, true); + } + return retval; } @@ -612,6 +619,15 @@ bool cpu_thread::check_state() noexcept { cpu_sleep(); cpu_sleep_called = true; + + if (s_tls_thread_slot != umax) + { + // Exclude inactive threads from the suspend list (optimization) + std::lock_guard lock(g_fxo->get()->cpu_suspend_lock); + g_fxo->get()->remove(this); + s_tls_thread_slot = -1; + } + continue; }