mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 03:32:55 +00:00
CPU preemption control: try to minimize sleep time gaps between setups
This commit is contained in:
parent
9c5108c1ca
commit
9d1ec0b319
@ -642,6 +642,8 @@ void cpu_thread::cpu_wait(bs_t<cpu_flag> old)
|
|||||||
thread_ctrl::wait_on(state, old);
|
thread_ctrl::wait_on(state, old);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static atomic_t<u32> s_dummy_atomic = 0;
|
||||||
|
|
||||||
bool cpu_thread::check_state() noexcept
|
bool cpu_thread::check_state() noexcept
|
||||||
{
|
{
|
||||||
bool cpu_sleep_called = false;
|
bool cpu_sleep_called = false;
|
||||||
@ -782,7 +784,7 @@ bool cpu_thread::check_state() noexcept
|
|||||||
if (cpu_flag::wait - state0)
|
if (cpu_flag::wait - state0)
|
||||||
{
|
{
|
||||||
// Yield itself
|
// Yield itself
|
||||||
state.wait(state1, atomic_wait_timeout{20'000});
|
s_dummy_atomic.wait(0, 1u << 30, atomic_wait_timeout{80'000});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const u128 bits = s_cpu_bits)
|
if (const u128 bits = s_cpu_bits)
|
||||||
@ -896,7 +898,8 @@ bool cpu_thread::check_state() noexcept
|
|||||||
if (state0 & cpu_flag::yield && cpu_flag::wait - state0)
|
if (state0 & cpu_flag::yield && cpu_flag::wait - state0)
|
||||||
{
|
{
|
||||||
// Short sleep when yield flag is present alone (makes no sense when other methods which can stop thread execution have been done)
|
// Short sleep when yield flag is present alone (makes no sense when other methods which can stop thread execution have been done)
|
||||||
state.wait(state1, atomic_wait_timeout{20'000});
|
// Pass a mask of a single bit which is often unused to avoid notifications
|
||||||
|
s_dummy_atomic.wait(0, 1u << 30, atomic_wait_timeout{80'000});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user