From 53fefc82c514ad92f09b4358074d3d090c222e88 Mon Sep 17 00:00:00 2001 From: Elad <18193363+elad335@users.noreply.github.com> Date: Thu, 21 May 2026 21:00:14 +0300 Subject: [PATCH] PPU LLVM: Fix core_lock locking Co-Authored-By: Megamouse <23019877+Megamouse@users.noreply.github.com> --- rpcs3/Emu/Cell/PPUThread.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 350f711f08..6f4b9dafb9 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -5336,11 +5336,26 @@ bool ppu_initialize(const ppu_module& info, bool check_only, u64 file_s , thread_op(work_cv, workload, cpu, info, cache_path, g_fxo->get().sem) , [&](u32 /*thread_index*/, thread_op& op) { + const bool to_lock = work_cv < workload.size() && (cpu ? !cpu->state.all_of(cpu_flag::exit) : !Emu.IsStopped()); + + if (!to_lock) + { + return false; + } + // Allocate "core" op.core_lock.lock(); // Second check before creating another thread - return work_cv < workload.size() && (cpu ? !cpu->state.all_of(cpu_flag::exit) : !Emu.IsStopped()); + const bool to_unlock = !(work_cv < workload.size() && (cpu ? !cpu->state.all_of(cpu_flag::exit) : !Emu.IsStopped())); + + if (to_unlock) + { + op.core_lock.unlock(); + return false; + } + + return true; }); threads.join();