Skip to content

Commit

Permalink
LV2: Optimization for timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Jun 12, 2024
1 parent 92ceabf commit 77320bc
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rpcs3/Emu/Cell/lv2/sys_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,12 @@ error_code sys_event_queue_receive(ppu_thread& ppu, u32 equeue_id, vm::ptr<sys_e
continue;
}

if (!atomic_storage<ppu_thread*>::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))
Expand Down
6 changes: 6 additions & 0 deletions rpcs3/Emu/Cell/lv2/sys_event_flag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ error_code sys_event_flag_wait(ppu_thread& ppu, u32 id, u64 bitptn, u32 mode, vm
continue;
}

if (!atomic_storage<ppu_thread*>::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))
Expand Down
6 changes: 6 additions & 0 deletions rpcs3/Emu/Cell/lv2/sys_lwmutex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions rpcs3/Emu/Cell/lv2/sys_mutex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ error_code sys_mutex_lock(ppu_thread& ppu, u32 mutex_id, u64 timeout)
continue;
}

if (!atomic_storage<ppu_thread*>::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;
Expand Down
6 changes: 6 additions & 0 deletions rpcs3/Emu/Cell/lv2/sys_rwlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ error_code sys_rwlock_rlock(ppu_thread& ppu, u32 rw_lock_id, u64 timeout)
continue;
}

if (!atomic_storage<ppu_thread*>::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))
Expand Down

0 comments on commit 77320bc

Please sign in to comment.