summaryrefslogtreecommitdiff
path: root/src/core/core.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/core.cpp')
-rw-r--r--src/core/core.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 066423f23..1e6be34c8 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -37,6 +37,9 @@ static void RunCpuCore(std::shared_ptr<Cpu> cpu_state) {
37System::ResultStatus System::RunLoop(bool tight_loop) { 37System::ResultStatus System::RunLoop(bool tight_loop) {
38 status = ResultStatus::Success; 38 status = ResultStatus::Success;
39 39
40 // Update thread_to_cpu in case Core 0 is run from a different host thread
41 thread_to_cpu[std::this_thread::get_id()] = cpu_cores[0];
42
40 if (GDBStub::IsServerEnabled()) { 43 if (GDBStub::IsServerEnabled()) {
41 GDBStub::HandlePacket(); 44 GDBStub::HandlePacket();
42 45
@@ -186,17 +189,21 @@ void System::Shutdown() {
186 gpu_core.reset(); 189 gpu_core.reset();
187 190
188 // Close all CPU/threading state 191 // Close all CPU/threading state
189 thread_to_cpu.clear(); 192 cpu_barrier->NotifyEnd();
190 for (auto& cpu_core : cpu_cores) {
191 cpu_core.reset();
192 }
193 for (auto& thread : cpu_core_threads) { 193 for (auto& thread : cpu_core_threads) {
194 thread->join(); 194 thread->join();
195 thread.reset(); 195 thread.reset();
196 } 196 }
197 thread_to_cpu.clear();
198 for (auto& cpu_core : cpu_cores) {
199 cpu_core.reset();
200 }
201 cpu_barrier.reset();
197 202
203 // Close core timing
198 CoreTiming::Shutdown(); 204 CoreTiming::Shutdown();
199 205
206 // Close app loader
200 app_loader.reset(); 207 app_loader.reset();
201 208
202 NGLOG_DEBUG(Core, "Shutdown OK"); 209 NGLOG_DEBUG(Core, "Shutdown OK");