mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-29 00:33:01 +00:00
Fixup and Improve CELL reservation notifications
This commit is contained in:
parent
6ddb21ab95
commit
33851d51ab
@ -3506,16 +3506,30 @@ static bool ppu_store_reservation(ppu_thread& ppu, u32 addr, u64 reg_value)
|
||||
|
||||
if (ppu.res_notify_time == (vm::reservation_acquire(notify) & -128))
|
||||
{
|
||||
ppu.state += cpu_flag::wait;
|
||||
vm::reservation_notifier(notify).notify_all();
|
||||
notified = true;
|
||||
}
|
||||
|
||||
if (!notified || (addr ^ notify) & -128)
|
||||
if (get_resrv_waiters_count(addr))
|
||||
{
|
||||
res.notify_all();
|
||||
if (!notified)
|
||||
{
|
||||
ppu.res_notify = addr;
|
||||
ppu.res_notify_time = rtime + 128;
|
||||
}
|
||||
else if ((addr ^ notify) & -128)
|
||||
{
|
||||
res.notify_all();
|
||||
ppu.res_notify = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ppu.res_notify = 0;
|
||||
}
|
||||
|
||||
ppu.res_notify = 0;
|
||||
static_cast<void>(ppu.test_stopped());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3546,7 +3560,9 @@ static bool ppu_store_reservation(ppu_thread& ppu, u32 addr, u64 reg_value)
|
||||
{
|
||||
if (ppu.res_notify_time == (vm::reservation_acquire(notify) & -128))
|
||||
{
|
||||
ppu.state += cpu_flag::wait;
|
||||
vm::reservation_notifier(notify).notify_all();
|
||||
static_cast<void>(ppu.test_stopped());
|
||||
}
|
||||
|
||||
ppu.res_notify = 0;
|
||||
|
@ -538,6 +538,8 @@ error_code sys_cond_wait(ppu_thread& ppu, u32 cond_id, u64 timeout)
|
||||
continue;
|
||||
}
|
||||
|
||||
ppu.state += cpu_flag::wait;
|
||||
|
||||
std::lock_guard lock(cond->mutex->mutex);
|
||||
|
||||
// Try to cancel the waiting
|
||||
|
@ -521,6 +521,8 @@ error_code sys_event_queue_receive(ppu_thread& ppu, u32 equeue_id, vm::ptr<sys_e
|
||||
continue;
|
||||
}
|
||||
|
||||
ppu.state += cpu_flag::wait;
|
||||
|
||||
if (!atomic_storage<ppu_thread*>::load(queue->pq))
|
||||
{
|
||||
// Waiters queue is empty, so the thread must have been signaled
|
||||
|
@ -240,6 +240,8 @@ error_code sys_event_flag_wait(ppu_thread& ppu, u32 id, u64 bitptn, u32 mode, vm
|
||||
continue;
|
||||
}
|
||||
|
||||
ppu.state += cpu_flag::wait;
|
||||
|
||||
if (!atomic_storage<ppu_thread*>::load(flag->sq))
|
||||
{
|
||||
// Waiters queue is empty, so the thread must have been signaled
|
||||
|
@ -572,6 +572,8 @@ error_code _sys_lwcond_queue_wait(ppu_thread& ppu, u32 lwcond_id, u32 lwmutex_id
|
||||
continue;
|
||||
}
|
||||
|
||||
ppu.state += cpu_flag::wait;
|
||||
|
||||
std::lock_guard lock(cond->mutex);
|
||||
|
||||
if (cond->unqueue(cond->sq, &ppu))
|
||||
|
@ -234,6 +234,8 @@ error_code _sys_lwmutex_lock(ppu_thread& ppu, u32 lwmutex_id, u64 timeout)
|
||||
continue;
|
||||
}
|
||||
|
||||
ppu.state += cpu_flag::wait;
|
||||
|
||||
if (!mutex->load_sq())
|
||||
{
|
||||
// Sleep queue is empty, so the thread must have been signaled
|
||||
|
@ -255,6 +255,8 @@ error_code sys_mutex_lock(ppu_thread& ppu, u32 mutex_id, u64 timeout)
|
||||
continue;
|
||||
}
|
||||
|
||||
ppu.state += cpu_flag::wait;
|
||||
|
||||
if (!atomic_storage<ppu_thread*>::load(mutex->control.raw().sq))
|
||||
{
|
||||
// Waiters queue is empty, so the thread must have been signaled
|
||||
|
@ -196,6 +196,8 @@ error_code sys_rwlock_rlock(ppu_thread& ppu, u32 rw_lock_id, u64 timeout)
|
||||
continue;
|
||||
}
|
||||
|
||||
ppu.state += cpu_flag::wait;
|
||||
|
||||
if (!atomic_storage<ppu_thread*>::load(rwlock->rq))
|
||||
{
|
||||
// Waiters queue is empty, so the thread must have been signaled
|
||||
|
@ -202,6 +202,8 @@ error_code sys_semaphore_wait(ppu_thread& ppu, u32 sem_id, u64 timeout)
|
||||
continue;
|
||||
}
|
||||
|
||||
ppu.state += cpu_flag::wait;
|
||||
|
||||
std::lock_guard lock(sem->mutex);
|
||||
|
||||
if (!sem->unqueue(sem->sq, &ppu))
|
||||
|
Loading…
x
Reference in New Issue
Block a user