summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/k_thread.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-08-19 00:42:46 +0200
committerGitHub <noreply@github.com>2021-08-19 00:42:46 +0200
commitaa40084c241129ef08081bae72bd5de1b4c86348 (patch)
treeb4f406cbf0f230cf9064040992ce3ef8bf54e5a7 /src/core/hle/kernel/k_thread.h
parentMerge pull request #6863 from spholz/fix-lan-play (diff)
parentcore: hle: kernel: Disable dispatch count tracking on single core. (diff)
downloadyuzu-aa40084c241129ef08081bae72bd5de1b4c86348.tar
yuzu-aa40084c241129ef08081bae72bd5de1b4c86348.tar.gz
yuzu-aa40084c241129ef08081bae72bd5de1b4c86348.tar.bz2
yuzu-aa40084c241129ef08081bae72bd5de1b4c86348.tar.lz
yuzu-aa40084c241129ef08081bae72bd5de1b4c86348.tar.xz
yuzu-aa40084c241129ef08081bae72bd5de1b4c86348.tar.zst
yuzu-aa40084c241129ef08081bae72bd5de1b4c86348.zip
Diffstat (limited to 'src/core/hle/kernel/k_thread.h')
-rw-r--r--src/core/hle/kernel/k_thread.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h
index c77f44ad4..e4c4c877d 100644
--- a/src/core/hle/kernel/k_thread.h
+++ b/src/core/hle/kernel/k_thread.h
@@ -450,16 +450,39 @@ public:
sleeping_queue = q;
}
+ [[nodiscard]] bool IsKernelThread() const {
+ return GetActiveCore() == 3;
+ }
+
+ [[nodiscard]] bool IsDispatchTrackingDisabled() const {
+ return is_single_core || IsKernelThread();
+ }
+
[[nodiscard]] s32 GetDisableDispatchCount() const {
+ if (IsDispatchTrackingDisabled()) {
+ // TODO(bunnei): Until kernel threads are emulated, we cannot enable/disable dispatch.
+ return 1;
+ }
+
return this->GetStackParameters().disable_count;
}
void DisableDispatch() {
+ if (IsDispatchTrackingDisabled()) {
+ // TODO(bunnei): Until kernel threads are emulated, we cannot enable/disable dispatch.
+ return;
+ }
+
ASSERT(GetCurrentThread(kernel).GetDisableDispatchCount() >= 0);
this->GetStackParameters().disable_count++;
}
void EnableDispatch() {
+ if (IsDispatchTrackingDisabled()) {
+ // TODO(bunnei): Until kernel threads are emulated, we cannot enable/disable dispatch.
+ return;
+ }
+
ASSERT(GetCurrentThread(kernel).GetDisableDispatchCount() > 0);
this->GetStackParameters().disable_count--;
}
@@ -708,6 +731,7 @@ private:
// For emulation
std::shared_ptr<Common::Fiber> host_context{};
+ bool is_single_core{};
// For debugging
std::vector<KSynchronizationObject*> wait_objects_for_debugging;
@@ -752,4 +776,16 @@ public:
}
};
+class KScopedDisableDispatch {
+public:
+ [[nodiscard]] explicit KScopedDisableDispatch(KernelCore& kernel_) : kernel{kernel_} {
+ GetCurrentThread(kernel).DisableDispatch();
+ }
+
+ ~KScopedDisableDispatch();
+
+private:
+ KernelCore& kernel;
+};
+
} // namespace Kernel