Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report deadlocked thread names in failures to stop emulation #9865

Merged
merged 3 commits into from
Feb 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the liberaty to remove this hack as I think all thread code paths are CELL_OK now.

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