Fix KProcess/SetThreadPriority PI CAS

The condition for exiting the CAS loops is incorrect in several places which leads to additional loops, while this doesn't make the behavior incorrect it does lead to redundant iterations. 

Co-authored-by: Billy Laws <blaws05@gmail.com>
This commit is contained in:
PixelyIon 2022-08-04 15:54:37 +05:30
parent 8fc3cc7a16
commit 68615703c1
No known key found for this signature in database
GPG Key ID: 11BC6C3201BC2C05
2 changed files with 3 additions and 3 deletions

View File

@ -365,7 +365,7 @@ namespace skyline::kernel::svc {
// If the new priority is equivalent to the current priority then we don't need to CAS
newPriority = thread->priority.load();
newPriority = std::min(newPriority, priority);
} while (newPriority != priority && thread->priority.compare_exchange_strong(newPriority, priority));
} while (newPriority != priority && !thread->priority.compare_exchange_strong(newPriority, priority));
state.scheduler->UpdatePriority(thread);
thread->UpdatePriorityInheritance();
}

View File

@ -181,7 +181,7 @@ namespace skyline::kernel::type {
do {
basePriority = state.thread->basePriority.load();
newPriority = std::min(basePriority, highestPriorityThread->priority.load());
} while (basePriority != newPriority && state.thread->priority.compare_exchange_strong(basePriority, newPriority));
} while (basePriority != newPriority && !state.thread->priority.compare_exchange_strong(basePriority, newPriority));
state.scheduler->UpdatePriority(state.thread);
} else {
i8 priority, basePriority;
@ -199,7 +199,7 @@ namespace skyline::kernel::type {
do {
ownerPriority = nextOwner->priority.load();
priority = std::min(ownerPriority, nextWaiter->priority.load());
} while (ownerPriority != priority && nextOwner->priority.compare_exchange_strong(ownerPriority, priority));
} while (ownerPriority != priority && !nextOwner->priority.compare_exchange_strong(ownerPriority, priority));
__atomic_store_n(mutex, nextOwner->waitTag | HandleWaitersBit, __ATOMIC_SEQ_CST);
} else {