Fix KProcess::MutexUnlock PI CAS

The PI CAS in `MutexUnlock` ends up loading `basePriority` rather than `priority` which could lead to an infinite CAS loop when `basePriority` doesn't equal to `priority` and the `highestPriorityThread`'s priority is lower than `basePriority`.
This commit is contained in:
Billy Laws 2022-08-06 15:54:57 +05:30 committed by PixelyIon
parent 850c0f4092
commit 5398eff045
No known key found for this signature in database
GPG Key ID: 11BC6C3201BC2C05

View File

@ -177,11 +177,10 @@ namespace skyline::kernel::type {
if (!waiters.empty()) {
// If there are threads still waiting on us then try to inherit their priority
auto highestPriorityThread{waiters.front()};
i8 newPriority, basePriority;
i8 newPriority, currentPriority{state.thread->priority.load()};
do {
basePriority = state.thread->basePriority.load();
newPriority = std::min(basePriority, highestPriorityThread->priority.load());
} while (basePriority != newPriority && !state.thread->priority.compare_exchange_strong(basePriority, newPriority));
newPriority = std::min(currentPriority, highestPriorityThread->priority.load());
} while (currentPriority != newPriority && !state.thread->priority.compare_exchange_strong(currentPriority, newPriority));
state.scheduler->UpdatePriority(state.thread);
} else {
i8 priority, basePriority;