Better thread yield support

This commit is contained in:
momo5502
2024-11-09 17:50:23 +01:00
parent 71232d51ab
commit 8f5600bc7c
3 changed files with 11 additions and 9 deletions

View File

@@ -2423,9 +2423,7 @@ namespace
t.await_time = convert_delay_interval_to_time_point(timeout.read());
}
c.win_emu.switch_thread = true;
c.emu.stop();
c.win_emu.yield_thread();
return STATUS_SUCCESS;
}
@@ -2444,8 +2442,7 @@ namespace
thread->exit_status = exit_status;
if (thread == c.proc.active_thread)
{
c.win_emu.switch_thread = true;
c.emu.stop();
c.win_emu.yield_thread();
}
return STATUS_SUCCESS;
@@ -2464,8 +2461,7 @@ namespace
auto& t = c.win_emu.current_thread();
t.await_time = convert_delay_interval_to_time_point(delay_interval.read());
c.win_emu.switch_thread = true;
c.emu.stop();
c.win_emu.yield_thread();
return STATUS_SUCCESS;
}
@@ -2508,8 +2504,7 @@ namespace
t.await_time = convert_delay_interval_to_time_point(timeout.read());
}
c.win_emu.switch_thread = true;
c.emu.stop();
c.win_emu.yield_thread();
return STATUS_SUCCESS;
}

View File

@@ -809,6 +809,12 @@ void windows_emulator::setup_process(const emulator_settings& settings)
switch_to_thread(*this, main_thread_id);
}
void windows_emulator::yield_thread()
{
this->switch_thread = true;
this->emu().stop();
}
void windows_emulator::perform_thread_switch()
{
this->switch_thread = false;

View File

@@ -92,6 +92,7 @@ public:
bool fuzzing{false};
bool switch_thread{false};
void yield_thread();
void perform_thread_switch();
private: