summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/kernel.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-11-26 05:46:17 +0100
committerbunnei <bunneidev@gmail.com>2021-12-07 01:39:17 +0100
commitabbea575cfcc9e933fbe8f277a5e9f754deb669d (patch)
tree50cf06afc61acb947ba8959a33c0e60b74951c1e /src/core/hle/kernel/kernel.cpp
parenthle: kernel: KSynchronizationObject: Fix variable shadowing. (diff)
downloadyuzu-abbea575cfcc9e933fbe8f277a5e9f754deb669d.tar
yuzu-abbea575cfcc9e933fbe8f277a5e9f754deb669d.tar.gz
yuzu-abbea575cfcc9e933fbe8f277a5e9f754deb669d.tar.bz2
yuzu-abbea575cfcc9e933fbe8f277a5e9f754deb669d.tar.lz
yuzu-abbea575cfcc9e933fbe8f277a5e9f754deb669d.tar.xz
yuzu-abbea575cfcc9e933fbe8f277a5e9f754deb669d.tar.zst
yuzu-abbea575cfcc9e933fbe8f277a5e9f754deb669d.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/kernel.cpp18
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 @@
#include "common/assert.h"
#include "common/logging/log.h"
#include "common/microprofile.h"
+#include "common/scope_exit.h"
#include "common/thread.h"
#include "common/thread_worker.h"
#include "core/arm/arm_interface.h"
@@ -90,6 +91,9 @@ struct KernelCore::Impl {
}
void Shutdown() {
+ is_shutting_down.store(true, std::memory_order_relaxed);
+ SCOPE_EXIT({ is_shutting_down.store(false, std::memory_order_relaxed); });
+
process_list.clear();
// Close all open server ports.
@@ -338,7 +342,16 @@ struct KernelCore::Impl {
is_phantom_mode_for_singlecore = value;
}
+ bool IsShuttingDown() const {
+ return is_shutting_down.load(std::memory_order_relaxed);
+ }
+
KThread* GetCurrentEmuThread() {
+ // If we are shutting down the kernel, none of this is relevant anymore.
+ if (IsShuttingDown()) {
+ return {};
+ }
+
const auto thread_id = GetCurrentHostThreadID();
if (thread_id >= Core::Hardware::NUM_CPU_CORES) {
return GetHostDummyThread();
@@ -754,6 +767,7 @@ struct KernelCore::Impl {
std::vector<std::unique_ptr<KThread>> dummy_threads;
bool is_multicore{};
+ std::atomic_bool is_shutting_down{};
bool is_phantom_mode_for_singlecore{};
u32 single_core_thread_id{};
@@ -1066,6 +1080,10 @@ bool KernelCore::IsMulticore() const {
return impl->is_multicore;
}
+bool KernelCore::IsShuttingDown() const {
+ return impl->IsShuttingDown();
+}
+
void KernelCore::ExceptionalExit() {
exception_exited = true;
Suspend(true);