From 48cd56acc2c55e80d7ae0943d4194ab43e009809 Mon Sep 17 00:00:00 2001 From: Eladash Date: Mon, 1 Mar 2021 00:06:48 +0200 Subject: [PATCH] Report deadlocked thread names in failures to stop emulation (#9865) * Report deadlocked thread names in failures to stop emulation Co-authored-by: Nekotekina --- Utilities/Thread.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index e9fa5218da..764e4acf89 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -2338,7 +2338,6 @@ bool thread_base::join(bool dtor) const // Hacked for too sleepy threads (1ms) TODO: make sure it's unneeded and remove const auto timeout = dtor && Emu.IsStopped() ? atomic_wait_timeout{1'000'000} : atomic_wait_timeout::inf; - bool warn = false; auto stamp0 = __rdtsc(); for (u64 i = 0; (m_sync & 3) <= 1; i++) @@ -2350,18 +2349,12 @@ bool thread_base::join(bool dtor) const break; } - if (i > 20 && Emu.IsStopped()) + if (i >= 16 && !(i & (i - 1)) && timeout != atomic_wait_timeout::inf) { - atomic_wait_engine::raw_notify(0, get_native_id()); - warn = true; + sig_log.error(u8"Thread [%s] is too sleepy. Waiting for it %.3fµs already!", *m_tname.load(), (__rdtsc() - stamp0) / (utils::get_tsc_freq() / 1000000.)); } } - if (warn) - { - sig_log.error(u8"Thread [%s] is too sleepy. Took %.3fµs to wake it up!", *m_tname.load(), (__rdtsc() - stamp0) / (utils::get_tsc_freq() / 1000000.)); - } - return (m_sync & 3) == 3; }