LV2: Optimization for timeout

This commit is contained in:
Elad Ashkenazi 2024-06-12 08:42:03 +03:00
parent cec976b70a
commit f58b418b7d
5 changed files with 30 additions and 0 deletions

View File

@ -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))

View File

@ -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))

View File

@ -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;

View File

@ -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;

View File

@ -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))