General: Fix Stop function

This commit is contained in:
Fernando Sahmkow 2020-03-11 20:44:53 -04:00
parent f370de84b1
commit e6f8bde74b
4 changed files with 25 additions and 5 deletions

View File

@ -61,6 +61,7 @@ void CoreTiming::Initialize(std::function<void(void)>&& on_thread_init_) {
void CoreTiming::Shutdown() { void CoreTiming::Shutdown() {
paused = true; paused = true;
shutting_down = true; shutting_down = true;
pause_event.Set();
event.Set(); event.Set();
timer_thread->join(); timer_thread->join();
ClearPendingEvents(); ClearPendingEvents();

View File

@ -119,6 +119,7 @@ struct KernelCore::Impl {
void Initialize(KernelCore& kernel) { void Initialize(KernelCore& kernel) {
Shutdown(); Shutdown();
RegisterHostThread();
InitializePhysicalCores(); InitializePhysicalCores();
InitializeSystemResourceLimit(kernel); InitializeSystemResourceLimit(kernel);
@ -135,6 +136,19 @@ struct KernelCore::Impl {
next_user_process_id = Process::ProcessIDMin; next_user_process_id = Process::ProcessIDMin;
next_thread_id = 1; next_thread_id = 1;
for (std::size_t i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) {
if (suspend_threads[i]) {
suspend_threads[i].reset();
}
}
for (std::size_t i = 0; i < cores.size(); i++) {
cores[i].Shutdown();
}
cores.clear();
registered_core_threads.reset();
process_list.clear(); process_list.clear();
current_process = nullptr; current_process = nullptr;
@ -154,6 +168,7 @@ struct KernelCore::Impl {
cores.clear(); cores.clear();
exclusive_monitor.reset(); exclusive_monitor.reset();
host_thread_ids.clear();
} }
void InitializePhysicalCores() { void InitializePhysicalCores() {

View File

@ -56,10 +56,12 @@ void Thread::Stop() {
Signal(); Signal();
kernel.GlobalHandleTable().Close(global_handle); kernel.GlobalHandleTable().Close(global_handle);
owner_process->UnregisterThread(this); if (owner_process) {
owner_process->UnregisterThread(this);
// Mark the TLS slot in the thread's page as free. // Mark the TLS slot in the thread's page as free.
owner_process->FreeTLSRegion(tls_address); owner_process->FreeTLSRegion(tls_address);
}
} }
global_handle = 0; global_handle = 0;
} }

View File

@ -89,8 +89,10 @@ void EmuThread::run() {
} }
running_guard = false; running_guard = false;
was_active = true; if (!stop_run) {
emit DebugModeEntered(); was_active = true;
emit DebugModeEntered();
}
} else if (exec_step) { } else if (exec_step) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} else { } else {