From 7c623f8301199b88bde039c70499f2c1ba319ed7 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Wed, 11 Jan 2023 20:41:33 +0000 Subject: [PATCH] Use a spinlock for thread waiter mutex Since the waitermutex is only ever locked for a short amount of time, spinning in contention-heavy scenarios ends up quite a bit more efficient than a kernel wait. --- app/src/main/cpp/skyline/kernel/types/KThread.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/cpp/skyline/kernel/types/KThread.h b/app/src/main/cpp/skyline/kernel/types/KThread.h index a39b6c00..47e09bf0 100644 --- a/app/src/main/cpp/skyline/kernel/types/KThread.h +++ b/app/src/main/cpp/skyline/kernel/types/KThread.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "KSyncObject.h" #include "KPrivateMemory.h" #include "KSharedMemory.h" @@ -62,7 +63,7 @@ namespace skyline { bool pendingYield{}; //!< If the thread has been yielded and hasn't been acted upon it yet bool forceYield{}; //!< If the thread has been forcefully yielded by another thread - std::recursive_mutex waiterMutex; //!< Synchronizes operations on mutation of the waiter members + RecursiveSpinLock waiterMutex; //!< Synchronizes operations on mutation of the waiter members u32 *waitMutex; //!< The key of the mutex which this thread is waiting on KHandle waitTag; //!< The handle of the thread which requested the mutex lock std::shared_ptr waitThread; //!< The thread which this thread is waiting on