LV2: Race condition fixup

This commit is contained in:
Elad Ashkenazi 2024-06-12 11:36:48 +03:00
parent f58b418b7d
commit caf81f1367
5 changed files with 5 additions and 0 deletions

View file

@ -524,6 +524,7 @@ error_code sys_event_queue_receive(ppu_thread& ppu, u32 equeue_id, vm::ptr<sys_e
if (!atomic_storage<ppu_thread*>::load(queue->pq))
{
// Waiters queue is empty, so the thread must have been signaled
queue->mutex.lock_unlock();
break;
}

View file

@ -243,6 +243,7 @@ error_code sys_event_flag_wait(ppu_thread& ppu, u32 id, u64 bitptn, u32 mode, vm
if (!atomic_storage<ppu_thread*>::load(flag->sq))
{
// Waiters queue is empty, so the thread must have been signaled
flag->mutex.lock_unlock();
break;
}

View file

@ -237,6 +237,7 @@ error_code _sys_lwmutex_lock(ppu_thread& ppu, u32 lwmutex_id, u64 timeout)
if (!mutex->load_sq())
{
// Sleep queue is empty, so the thread must have been signaled
mutex->mutex.lock_unlock();
break;
}

View file

@ -258,6 +258,7 @@ error_code sys_mutex_lock(ppu_thread& ppu, u32 mutex_id, u64 timeout)
if (!atomic_storage<ppu_thread*>::load(mutex->control.raw().sq))
{
// Waiters queue is empty, so the thread must have been signaled
mutex->mutex.lock_unlock();
break;
}

View file

@ -199,6 +199,7 @@ error_code sys_rwlock_rlock(ppu_thread& ppu, u32 rw_lock_id, u64 timeout)
if (!atomic_storage<ppu_thread*>::load(rwlock->rq))
{
// Waiters queue is empty, so the thread must have been signaled
rwlock->mutex.lock_unlock();
break;
}