diff options
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index cf155ff66..1a47d4716 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include "common/assert.h" | 14 | #include "common/assert.h" |
| 15 | #include "common/logging/log.h" | 15 | #include "common/logging/log.h" |
| 16 | #include "common/microprofile.h" | 16 | #include "common/microprofile.h" |
| 17 | #include "common/scope_exit.h" | ||
| 17 | #include "common/thread.h" | 18 | #include "common/thread.h" |
| 18 | #include "common/thread_worker.h" | 19 | #include "common/thread_worker.h" |
| 19 | #include "core/arm/arm_interface.h" | 20 | #include "core/arm/arm_interface.h" |
| @@ -90,6 +91,9 @@ struct KernelCore::Impl { | |||
| 90 | } | 91 | } |
| 91 | 92 | ||
| 92 | void Shutdown() { | 93 | void Shutdown() { |
| 94 | is_shutting_down.store(true, std::memory_order_relaxed); | ||
| 95 | SCOPE_EXIT({ is_shutting_down.store(false, std::memory_order_relaxed); }); | ||
| 96 | |||
| 93 | process_list.clear(); | 97 | process_list.clear(); |
| 94 | 98 | ||
| 95 | // Close all open server ports. | 99 | // Close all open server ports. |
| @@ -338,7 +342,16 @@ struct KernelCore::Impl { | |||
| 338 | is_phantom_mode_for_singlecore = value; | 342 | is_phantom_mode_for_singlecore = value; |
| 339 | } | 343 | } |
| 340 | 344 | ||
| 345 | bool IsShuttingDown() const { | ||
| 346 | return is_shutting_down.load(std::memory_order_relaxed); | ||
| 347 | } | ||
| 348 | |||
| 341 | KThread* GetCurrentEmuThread() { | 349 | KThread* GetCurrentEmuThread() { |
| 350 | // If we are shutting down the kernel, none of this is relevant anymore. | ||
| 351 | if (IsShuttingDown()) { | ||
| 352 | return {}; | ||
| 353 | } | ||
| 354 | |||
| 342 | const auto thread_id = GetCurrentHostThreadID(); | 355 | const auto thread_id = GetCurrentHostThreadID(); |
| 343 | if (thread_id >= Core::Hardware::NUM_CPU_CORES) { | 356 | if (thread_id >= Core::Hardware::NUM_CPU_CORES) { |
| 344 | return GetHostDummyThread(); | 357 | return GetHostDummyThread(); |
| @@ -754,6 +767,7 @@ struct KernelCore::Impl { | |||
| 754 | std::vector<std::unique_ptr<KThread>> dummy_threads; | 767 | std::vector<std::unique_ptr<KThread>> dummy_threads; |
| 755 | 768 | ||
| 756 | bool is_multicore{}; | 769 | bool is_multicore{}; |
| 770 | std::atomic_bool is_shutting_down{}; | ||
| 757 | bool is_phantom_mode_for_singlecore{}; | 771 | bool is_phantom_mode_for_singlecore{}; |
| 758 | u32 single_core_thread_id{}; | 772 | u32 single_core_thread_id{}; |
| 759 | 773 | ||
| @@ -1066,6 +1080,10 @@ bool KernelCore::IsMulticore() const { | |||
| 1066 | return impl->is_multicore; | 1080 | return impl->is_multicore; |
| 1067 | } | 1081 | } |
| 1068 | 1082 | ||
| 1083 | bool KernelCore::IsShuttingDown() const { | ||
| 1084 | return impl->IsShuttingDown(); | ||
| 1085 | } | ||
| 1086 | |||
| 1069 | void KernelCore::ExceptionalExit() { | 1087 | void KernelCore::ExceptionalExit() { |
| 1070 | exception_exited = true; | 1088 | exception_exited = true; |
| 1071 | Suspend(true); | 1089 | Suspend(true); |