summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/k_thread.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2022-01-22 02:10:11 +0100
committerbunnei <bunneidev@gmail.com>2022-01-22 02:12:06 +0100
commit615fb40416b9ee10abf40a036b31d1540886a9b8 (patch)
tree8220ac1a9435933b995c4eab0e2e334daad3af11 /src/core/hle/kernel/k_thread.cpp
parenthle: kernel: Remove redundant tracking of dummy threads. (diff)
downloadyuzu-615fb40416b9ee10abf40a036b31d1540886a9b8.tar
yuzu-615fb40416b9ee10abf40a036b31d1540886a9b8.tar.gz
yuzu-615fb40416b9ee10abf40a036b31d1540886a9b8.tar.bz2
yuzu-615fb40416b9ee10abf40a036b31d1540886a9b8.tar.lz
yuzu-615fb40416b9ee10abf40a036b31d1540886a9b8.tar.xz
yuzu-615fb40416b9ee10abf40a036b31d1540886a9b8.tar.zst
yuzu-615fb40416b9ee10abf40a036b31d1540886a9b8.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/k_thread.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp
index 4cbf12c11..f42abb8a1 100644
--- a/src/core/hle/kernel/k_thread.cpp
+++ b/src/core/hle/kernel/k_thread.cpp
@@ -1075,12 +1075,46 @@ ResultCode KThread::Sleep(s64 timeout) {
return ResultSuccess;
}
+void KThread::IfDummyThreadTryWait() {
+ if (!IsDummyThread()) {
+ return;
+ }
+
+ if (GetState() != ThreadState::Waiting) {
+ return;
+ }
+
+ // Block until we can grab the lock.
+ KScopedSpinLock lk{dummy_wait_lock};
+}
+
+void KThread::IfDummyThreadBeginWait() {
+ if (!IsDummyThread()) {
+ return;
+ }
+
+ // Ensure the thread will block when IfDummyThreadTryWait is called.
+ dummy_wait_lock.Lock();
+}
+
+void KThread::IfDummyThreadEndWait() {
+ if (!IsDummyThread()) {
+ return;
+ }
+
+ // Ensure the thread will no longer block.
+ dummy_wait_lock.Unlock();
+}
+
void KThread::BeginWait(KThreadQueue* queue) {
// Set our state as waiting.
SetState(ThreadState::Waiting);
// Set our wait queue.
wait_queue = queue;
+
+ // Special case for dummy threads to ensure they block.
+ IfDummyThreadBeginWait();
}
void KThread::NotifyAvailable(KSynchronizationObject* signaled_object, ResultCode wait_result_) {
@@ -1106,6 +1140,9 @@ void KThread::EndWait(ResultCode wait_result_) {
}
wait_queue->EndWait(this, wait_result_);
+
+ // Special case for dummy threads to wakeup if necessary.
+ IfDummyThreadEndWait();
}
}