From 10caa2981fffd46580506776ed8529576e0cfb50 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 23 Oct 2020 13:00:01 +0300 Subject: [PATCH] Improve raw_notify a bit --- Utilities/Thread.cpp | 12 +++++++++++- Utilities/Thread.h | 1 + rpcs3/Emu/Cell/lv2/sys_spu.cpp | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 820fd99b5..47fc3b3ed 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1899,7 +1899,17 @@ void thread_base::initialize(void (*error_cb)(), bool(*wait_cb)(const void*)) void thread_base::notify_abort() noexcept { m_signal.try_inc(); - atomic_storage_futex::raw_notify(+m_state_notifier); + + while (auto ptr = m_state_notifier.load()) + { + // Since this function is not perfectly implemented, run it in a loop + atomic_storage_futex::raw_notify(ptr); + + if (m_state_notifier.load() == ptr) + { + break; + } + } } bool thread_base::finalize(thread_state result_state) noexcept diff --git a/Utilities/Thread.h b/Utilities/Thread.h index 0a38703da..20aa45fcc 100644 --- a/Utilities/Thread.h +++ b/Utilities/Thread.h @@ -311,6 +311,7 @@ class named_thread final : public Context, result_storage_t, thread_bas if (_this->m_state >= thread_state::aborting) { + _this->m_state_notifier.store(data); return false; } diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.cpp b/rpcs3/Emu/Cell/lv2/sys_spu.cpp index 728d67d58..c87ee013a 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_spu.cpp @@ -1915,7 +1915,7 @@ error_code sys_isolated_spu_create(ppu_thread& ppu, vm::ptr id, vm::ptr +template error_code raw_spu_destroy(ppu_thread& ppu, u32 id) { const u32 idm_id = spu_thread::find_raw_spu(id);