Skip to content

Commit

Permalink
LV2/Timers: Include notification time
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Jun 5, 2023
1 parent ee5525f commit 5845ede
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions rpcs3/Emu/Cell/lv2/sys_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ lv2_timer_thread::lv2_timer_thread()
void lv2_timer_thread::operator()()
{
u64 sleep_time = 0;
u64 old_now = umax;

while (true)
{
Expand All @@ -123,7 +124,7 @@ void lv2_timer_thread::operator()()
sleep_time = std::min(sleep_time, u64{umax} / 100) * 100 / g_cfg.core.clocks_scale;
}

thread_ctrl::wait_for_accurate(sleep_time);
thread_ctrl::wait_for_accurate(utils::sub_saturate<u64>(sleep_time, get_guest_system_time() - old_now));

if (thread_ctrl::state() == thread_state::aborting)
{
Expand All @@ -138,15 +139,15 @@ void lv2_timer_thread::operator()()
continue;
}

const u64 _now = get_guest_system_time();
old_now = get_guest_system_time();

reader_lock lock(mutex);

for (const auto& timer : timers)
{
while (lv2_obj::check(timer))
{
if (const u64 advised_sleep_time = timer->check(_now))
if (const u64 advised_sleep_time = timer->check(old_now))
{
if (sleep_time > advised_sleep_time)
{
Expand Down

0 comments on commit 5845ede

Please sign in to comment.