From 284ac53d884a9106230faf0417d8b50939cbb710 Mon Sep 17 00:00:00 2001 From: PixelyIon Date: Thu, 14 Jul 2022 20:30:04 +0530 Subject: [PATCH] Fix KThread Priority Inheritance CAS The CAS condition for KThread PI was inverted which lead to entirely incorrect behavior for CAS conditions which while it might work in the vast majority of cases would lead to significantly inaccurate behavior. --- app/src/main/cpp/skyline/kernel/types/KThread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/cpp/skyline/kernel/types/KThread.cpp b/app/src/main/cpp/skyline/kernel/types/KThread.cpp index 1ecc5e65..a054f4b1 100644 --- a/app/src/main/cpp/skyline/kernel/types/KThread.cpp +++ b/app/src/main/cpp/skyline/kernel/types/KThread.cpp @@ -284,7 +284,7 @@ namespace skyline::kernel::type { ownerPriority = waitingOn->priority.load(); if (ownerPriority <= currentPriority) return; - } while (waitingOn->priority.compare_exchange_strong(ownerPriority, currentPriority)); + } while (!waitingOn->priority.compare_exchange_strong(ownerPriority, currentPriority)); if (ownerPriority != currentPriority) { std::scoped_lock waiterLock{waitingOn->waiterMutex};