Atomic waiting refactoring (#9208)

* Use atomic waitables instead instead of global thread wait as often as possible.
* Add ::is_stopped() and and ::is_paued() which can be used in atomic loops and with atomic wait. (constexpr cpu flags test functions)
* Fix notification bug of sys_spu_thread_group_exit/terminate. (old bug, enhanced by #9117)
* Function time statistics at Emu.Stop() restored. (instead of current "X syscall failed with 0x00000000 : 0")
This commit is contained in:
Eladash 2021-02-13 16:50:07 +02:00 committed by GitHub
parent cf384795d2
commit f43260bd58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 375 additions and 234 deletions

View file

@ -19,7 +19,8 @@ void lv2_int_serv::exec()
{ ppu_cmd::sleep, 0 }
});
thread_ctrl::notify(*thread);
thread->cmd_notify++;
thread->cmd_notify.notify_one();
}
bool ppu_thread_exit(ppu_thread& ppu);
@ -32,7 +33,8 @@ void lv2_int_serv::join()
std::bit_cast<u64>(&ppu_thread_exit)
});
thread_ctrl::notify(*thread);
thread->cmd_notify++;
thread->cmd_notify.notify_one();
(*thread)();
idm::remove_verify<named_thread<ppu_thread>>(thread->id, static_cast<std::weak_ptr<named_thread<ppu_thread>>>(thread));
@ -114,7 +116,7 @@ error_code _sys_interrupt_thread_establish(ppu_thread& ppu, vm::ptr<u32> ih, u32
result = std::make_shared<lv2_int_serv>(it, arg1, arg2);
tag->handler = result;
it->state -= cpu_flag::stop;
thread_ctrl::notify(*it);
it->state.notify_one(cpu_flag::stop);
return result;
});