mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-14 18:58:36 +12:00
sys_ppu: Hotfix for detached threads
This commit is contained in:
parent
ffd5a9e91c
commit
b05b16aedc
1 changed files with 11 additions and 14 deletions
|
@ -41,27 +41,24 @@ void _sys_ppu_thread_exit(ppu_thread& ppu, u64 errorcode)
|
||||||
|
|
||||||
if (jid == umax)
|
if (jid == umax)
|
||||||
{
|
{
|
||||||
// Detach detached thread, id will be removed on cleanup
|
// Simple structure to cleanup previous thread, because can't remove its own thread
|
||||||
static thread_local struct cleanup_t
|
struct ppu_thread_cleaner
|
||||||
{
|
{
|
||||||
const u32 id;
|
atomic_t<u32> id = 0;
|
||||||
|
};
|
||||||
|
|
||||||
cleanup_t(u32 id)
|
auto cleaner = g_fxo->get<ppu_thread_cleaner>();
|
||||||
: id(id)
|
|
||||||
|
if (cleaner->id || !cleaner->id.compare_and_swap_test(0, ppu.id)) [[likely]]
|
||||||
|
{
|
||||||
|
if (u32 old_id = cleaner->id.exchange(ppu.id))
|
||||||
{
|
{
|
||||||
}
|
if (!idm::remove<named_thread<ppu_thread>>(old_id))
|
||||||
|
|
||||||
cleanup_t(const cleanup_t&) = delete;
|
|
||||||
|
|
||||||
~cleanup_t()
|
|
||||||
{
|
|
||||||
if (!idm::remove<named_thread<ppu_thread>>(id))
|
|
||||||
{
|
{
|
||||||
sys_ppu_thread.fatal("Failed to remove detached thread! (id=0x%x)", id);
|
sys_ppu_thread.fatal("Failed to remove detached thread 0x%x", old_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
to_cleanup(ppu.id);
|
|
||||||
}
|
}
|
||||||
else if (jid != 0)
|
else if (jid != 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue