diff --git a/rpcs3/Emu/Cell/lv2/lv2.cpp b/rpcs3/Emu/Cell/lv2/lv2.cpp index 190594cc01..0eb6cbccd8 100644 --- a/rpcs3/Emu/Cell/lv2/lv2.cpp +++ b/rpcs3/Emu/Cell/lv2/lv2.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include "stdafx.h" #include "Emu/System.h" #include "Emu/Cell/PPUFunction.h" @@ -1063,7 +1063,15 @@ void lv2_obj::awake(cpu_thread& cpu, u32 prio) std::lock_guard lock(g_mutex); - if (prio == -4) + if (prio < INT32_MAX) + { + // Priority set + if (static_cast(cpu).prio.exchange(prio) == prio || !unqueue(g_ppu, &cpu)) + { + return; + } + } + else if (prio == -4) { // Yield command const u64 start_time = get_system_time(); @@ -1087,12 +1095,6 @@ void lv2_obj::awake(cpu_thread& cpu, u32 prio) static_cast(cpu).start_time = start_time; } - if (prio < INT32_MAX && !unqueue(g_ppu, &cpu)) - { - // Priority set - return; - } - // Emplace current thread for (std::size_t i = 0; i <= g_ppu.size(); i++) { diff --git a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp index 7f6c7352a7..1f5a0f36bc 100644 --- a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp @@ -206,7 +206,7 @@ error_code sys_ppu_thread_set_priority(ppu_thread& ppu, u32 thread_id, s32 prio) const auto thread = idm::check>(thread_id, [&](ppu_thread& thread) { - if (thread.prio != prio && thread.prio.exchange(prio) != prio) + if (thread.prio != prio) { lv2_obj::awake(thread, prio); }