Improve cpu_flag::yield handling

This commit is contained in:
Elad.Ash 2024-02-10 18:16:01 +02:00
parent ec59f4d37e
commit 148edc005a
2 changed files with 6 additions and 2 deletions

View file

@ -952,7 +952,7 @@ bool cpu_thread::check_state() noexcept
continue; continue;
} }
if (state0 & cpu_flag::yield && cpu_flag::wait - state0 && cpu_can_stop) if (state0 & cpu_flag::yield && cpu_can_stop)
{ {
if (auto spu = try_get<spu_thread>()) if (auto spu = try_get<spu_thread>())
{ {

View file

@ -1763,9 +1763,13 @@ void lv2_obj::schedule_all(u64 current_time)
if (target->state & cpu_flag::suspend) if (target->state & cpu_flag::suspend)
{ {
ppu_log.trace("schedule(): %s", target->id); ppu_log.trace("schedule(): %s", target->id);
// Remove yield if it was sleeping until now
const bs_t<cpu_flag> remove_yield = target->start_time == 0 ? +cpu_flag::suspend : (cpu_flag::yield + cpu_flag::preempt);
target->start_time = 0; target->start_time = 0;
if ((target->state.fetch_op(FN(x += cpu_flag::signal, x -= cpu_flag::suspend, void())) & (cpu_flag::wait + cpu_flag::signal)) != cpu_flag::wait) if ((target->state.fetch_op(FN(x += cpu_flag::signal, x -= cpu_flag::suspend, x-= remove_yield, void())) & (cpu_flag::wait + cpu_flag::signal)) != cpu_flag::wait)
{ {
continue; continue;
} }