Skip to content

Commit

Permalink
Report deadlocked thread names in failures to stop emulation (#9865)
Browse files Browse the repository at this point in the history
* Report deadlocked thread names in failures to stop emulation

Co-authored-by: Nekotekina <nekotekina@gmail.com>
  • Loading branch information
elad335 and Nekotekina committed Feb 28, 2021
1 parent 71e16bf commit 48cd56a
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions Utilities/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand All @@ -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;
}

Expand Down

0 comments on commit 48cd56a

Please sign in to comment.