mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-29 15:15:30 +03:00
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:
parent
850c0f4092
commit
5398eff045
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user