mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-12-25 10:52:48 -06:00
kernel/thread: Amend condition within UpdatePriority()
This condition was checking against the nominal thread priority, whereas the kernel itself checks against the current priority instead. We were also assigning the nominal priority, when we should be assigning current_priority, which takes priority inheritance into account. This can lead to the incorrect priority being assigned to a thread. Given we recursively update the relevant threads, we don't need to go through the whole mutex waiter list. This matches what the kernel does as well (only accessing the first entry within the waiting list).
This commit is contained in:
parent
0b78cfcc53
commit
39483b92b7
1 changed files with 3 additions and 3 deletions
|
@ -305,9 +305,9 @@ void Thread::RemoveMutexWaiter(SharedPtr<Thread> thread) {
|
||||||
void Thread::UpdatePriority() {
|
void Thread::UpdatePriority() {
|
||||||
// Find the highest priority among all the threads that are waiting for this thread's lock
|
// Find the highest priority among all the threads that are waiting for this thread's lock
|
||||||
u32 new_priority = nominal_priority;
|
u32 new_priority = nominal_priority;
|
||||||
for (const auto& thread : wait_mutex_threads) {
|
if (!wait_mutex_threads.empty()) {
|
||||||
if (thread->nominal_priority < new_priority)
|
if (wait_mutex_threads.front()->current_priority < new_priority)
|
||||||
new_priority = thread->nominal_priority;
|
new_priority = wait_mutex_threads.front()->current_priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_priority == current_priority)
|
if (new_priority == current_priority)
|
||||||
|
|
Loading…
Reference in a new issue