mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-26 12:42:41 +01:00
lv2: Reimplement sys_timer_usleep
- Matches ps3 accuracy for all tested values with few exceptions - Do not enter the host OS kernel if waiting for less than 500us to avoid scheduler issues
This commit is contained in:
parent
2adb2ebb00
commit
be13a776f4
@ -122,6 +122,12 @@ struct lv2_obj
|
||||
sleep_timeout(thread, timeout);
|
||||
}
|
||||
|
||||
static void yield(cpu_thread& thread)
|
||||
{
|
||||
vm::temporary_unlock(thread);
|
||||
awake(thread, -4);
|
||||
}
|
||||
|
||||
// Schedule the thread
|
||||
static void awake(cpu_thread&, u32 prio);
|
||||
|
||||
|
@ -294,14 +294,28 @@ error_code sys_timer_usleep(ppu_thread& ppu, u64 sleep_time)
|
||||
|
||||
sys_timer.trace("sys_timer_usleep(sleep_time=0x%llx)", sleep_time);
|
||||
|
||||
u64 passed = 0;
|
||||
|
||||
lv2_obj::sleep(ppu, std::max<u64>(1, sleep_time));
|
||||
|
||||
while (sleep_time >= passed)
|
||||
if (sleep_time)
|
||||
{
|
||||
thread_ctrl::wait_for(std::max<u64>(1, sleep_time - passed));
|
||||
passed = get_system_time() - ppu.start_time;
|
||||
u64 passed = 0;
|
||||
u64 remaining;
|
||||
|
||||
lv2_obj::sleep(ppu, sleep_time);
|
||||
|
||||
while (sleep_time > passed)
|
||||
{
|
||||
remaining = sleep_time - passed;
|
||||
|
||||
if (remaining > 500)
|
||||
thread_ctrl::wait_for(remaining - (remaining % 500));
|
||||
else
|
||||
busy_wait(4000);
|
||||
|
||||
passed = (get_system_time() - ppu.start_time);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lv2_obj::yield(ppu);
|
||||
}
|
||||
|
||||
return CELL_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user