From 938ca90a02c055816156ba30bd91c6860860f45e Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Mon, 1 Jun 2020 02:27:33 +0300 Subject: [PATCH] Improve Stop Watchdog Prevent termination if PPU LLVM compilation is in progress. --- rpcs3/Emu/Cell/PPUThread.cpp | 7 +++++++ rpcs3/Emu/System.cpp | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index be49d8f4ac..9455c0a6b3 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -66,6 +66,8 @@ const bool s_use_ssse3 = utils::has_ssse3(); extern u64 get_guest_system_time(); +extern atomic_t g_watchdog_hold_ctr; + extern atomic_t g_progr; extern atomic_t g_progr_ptotal; extern atomic_t g_progr_pdone; @@ -1678,6 +1680,9 @@ extern void ppu_initialize(const ppu_module& info) atomic_t index = 0; }; + // Prevent watchdog thread from terminating + g_watchdog_hold_ctr++; + named_thread_group threads(fmt::format("PPUW.%u.", ++g_fxo->get()->index), thread_count, [&]() { // Set low priority @@ -1708,6 +1713,8 @@ extern void ppu_initialize(const ppu_module& info) threads.join(); + g_watchdog_hold_ctr--; + if (Emu.IsStopped() || !get_current_cpu_thread()) { return; diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 7ae3a556b3..fa15e33b92 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -59,6 +59,8 @@ bool g_use_rtm; std::string g_cfg_defaults; +atomic_t g_watchdog_hold_ctr{0}; + extern void ppu_load_exec(const ppu_exec_object&); extern void spu_load_exec(const spu_exec_object&); extern void ppu_initialize(const ppu_module&); @@ -1710,7 +1712,7 @@ void Emulator::Stop(bool restart) named_thread stop_watchdog("Stop Watchdog", [&]() { - for (uint i = 0; thread_ctrl::state() != thread_state::aborting; i++) + for (uint i = 0; thread_ctrl::state() != thread_state::aborting;) { // We don't need accurate timekeeping, using clocks may interfere with debugging if (i >= 1000) @@ -1721,6 +1723,12 @@ void Emulator::Stop(bool restart) } thread_ctrl::wait_for(5'000); + + if (!g_watchdog_hold_ctr) + { + // Don't count if there are still uninterruptable threads like PPU LLVM workers + i++; + } } });