mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-14 02:38:37 +12: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
2 changed files with 27 additions and 7 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue