diff --git a/rpcs3/Emu/Cell/lv2/sys_event.cpp b/rpcs3/Emu/Cell/lv2/sys_event.cpp index 26d9ffd590..def5c433d2 100644 --- a/rpcs3/Emu/Cell/lv2/sys_event.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_event.cpp @@ -521,6 +521,12 @@ error_code sys_event_queue_receive(ppu_thread& ppu, u32 equeue_id, vm::ptr::load(queue->pq)) + { + // Waiters queue is empty, so the thread must have been signaled + break; + } + std::lock_guard lock(queue->mutex); if (!queue->unqueue(queue->pq, &ppu)) diff --git a/rpcs3/Emu/Cell/lv2/sys_event_flag.cpp b/rpcs3/Emu/Cell/lv2/sys_event_flag.cpp index 26f8f4468b..639e2db586 100644 --- a/rpcs3/Emu/Cell/lv2/sys_event_flag.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_event_flag.cpp @@ -240,6 +240,12 @@ error_code sys_event_flag_wait(ppu_thread& ppu, u32 id, u64 bitptn, u32 mode, vm continue; } + if (!atomic_storage::load(flag->sq)) + { + // Waiters queue is empty, so the thread must have been signaled + break; + } + std::lock_guard lock(flag->mutex); if (!flag->unqueue(flag->sq, &ppu)) diff --git a/rpcs3/Emu/Cell/lv2/sys_lwmutex.cpp b/rpcs3/Emu/Cell/lv2/sys_lwmutex.cpp index cfe5b7f933..1180edbbb2 100644 --- a/rpcs3/Emu/Cell/lv2/sys_lwmutex.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_lwmutex.cpp @@ -234,6 +234,12 @@ error_code _sys_lwmutex_lock(ppu_thread& ppu, u32 lwmutex_id, u64 timeout) continue; } + if (!mutex->load_sq()) + { + // Sleep queue is empty, so the thread must have been signaled + break; + } + std::lock_guard lock(mutex->mutex); bool success = false; diff --git a/rpcs3/Emu/Cell/lv2/sys_mutex.cpp b/rpcs3/Emu/Cell/lv2/sys_mutex.cpp index 42365fe9cc..fe9232724d 100644 --- a/rpcs3/Emu/Cell/lv2/sys_mutex.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_mutex.cpp @@ -255,6 +255,12 @@ error_code sys_mutex_lock(ppu_thread& ppu, u32 mutex_id, u64 timeout) continue; } + if (!atomic_storage::load(mutex->control.raw().sq)) + { + // Waiters queue is empty, so the thread must have been signaled + break; + } + std::lock_guard lock(mutex->mutex); bool success = false; diff --git a/rpcs3/Emu/Cell/lv2/sys_rwlock.cpp b/rpcs3/Emu/Cell/lv2/sys_rwlock.cpp index 3a75aea91e..7736c6d958 100644 --- a/rpcs3/Emu/Cell/lv2/sys_rwlock.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_rwlock.cpp @@ -196,6 +196,12 @@ error_code sys_rwlock_rlock(ppu_thread& ppu, u32 rw_lock_id, u64 timeout) continue; } + if (!atomic_storage::load(rwlock->rq)) + { + // Waiters queue is empty, so the thread must have been signaled + break; + } + std::lock_guard lock(rwlock->mutex); if (!rwlock->unqueue(rwlock->rq, &ppu))