PPU thread scheduler

This commit is contained in:
Nekotekina 2017-02-06 21:36:46 +03:00
parent e4962054a4
commit 598c90f376
41 changed files with 699 additions and 259 deletions

View file

@ -89,6 +89,8 @@ cpu_thread::cpu_thread(u32 id)
bool cpu_thread::check_state()
{
bool cpu_sleep_called = false;
while (true)
{
if (test(state & cpu_flag::exit))
@ -96,11 +98,23 @@ bool cpu_thread::check_state()
return true;
}
if (test(state & cpu_flag::signal) && state.test_and_reset(cpu_flag::signal))
{
cpu_sleep_called = false;
}
if (!test(state & (cpu_state_pause + cpu_flag::dbg_global_stop)))
{
break;
}
if (test(state & cpu_flag::suspend) && !cpu_sleep_called)
{
cpu_sleep();
cpu_sleep_called = true;
continue;
}
thread_ctrl::wait();
}
@ -126,12 +140,6 @@ void cpu_thread::run()
notify();
}
void cpu_thread::set_signal()
{
verify("cpu_flag::signal" HERE), !state.test_and_set(cpu_flag::signal);
notify();
}
std::string cpu_thread::dump() const
{
return fmt::format("Type: %s\n" "State: %s\n", typeid(*this).name(), state.load());