diff options
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index d44010824..3a5a67450 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -105,15 +105,15 @@ void Thread::Stop() { | |||
| 105 | 105 | ||
| 106 | WakeupAllWaitingThreads(); | 106 | WakeupAllWaitingThreads(); |
| 107 | 107 | ||
| 108 | // Release all the mutexes that this thread holds | ||
| 109 | ReleaseThreadMutexes(this); | ||
| 110 | |||
| 111 | // Clean up any dangling references in objects that this thread was waiting for | 108 | // Clean up any dangling references in objects that this thread was waiting for |
| 112 | for (auto& wait_object : wait_objects) { | 109 | for (auto& wait_object : wait_objects) { |
| 113 | wait_object->RemoveWaitingThread(this); | 110 | wait_object->RemoveWaitingThread(this); |
| 114 | } | 111 | } |
| 115 | wait_objects.clear(); | 112 | wait_objects.clear(); |
| 116 | 113 | ||
| 114 | // Release all the mutexes that this thread holds | ||
| 115 | ReleaseThreadMutexes(this); | ||
| 116 | |||
| 117 | // Mark the TLS slot in the thread's page as free. | 117 | // Mark the TLS slot in the thread's page as free. |
| 118 | u32 tls_page = (tls_address - Memory::TLS_AREA_VADDR) / Memory::PAGE_SIZE; | 118 | u32 tls_page = (tls_address - Memory::TLS_AREA_VADDR) / Memory::PAGE_SIZE; |
| 119 | u32 tls_slot = | 119 | u32 tls_slot = |
| @@ -515,8 +515,21 @@ void Thread::SetPriority(s32 priority) { | |||
| 515 | nominal_priority = current_priority = priority; | 515 | nominal_priority = current_priority = priority; |
| 516 | } | 516 | } |
| 517 | 517 | ||
| 518 | void Thread::UpdatePriority() { | ||
| 519 | s32 best_priority = nominal_priority; | ||
| 520 | for (auto& mutex : held_mutexes) { | ||
| 521 | if (mutex->priority < best_priority) | ||
| 522 | best_priority = mutex->priority; | ||
| 523 | } | ||
| 524 | BoostPriority(best_priority); | ||
| 525 | } | ||
| 526 | |||
| 518 | void Thread::BoostPriority(s32 priority) { | 527 | void Thread::BoostPriority(s32 priority) { |
| 519 | ready_queue.move(this, current_priority, priority); | 528 | // If thread was ready, adjust queues |
| 529 | if (status == THREADSTATUS_READY) | ||
| 530 | ready_queue.move(this, current_priority, priority); | ||
| 531 | else | ||
| 532 | ready_queue.prepare(priority); | ||
| 520 | current_priority = priority; | 533 | current_priority = priority; |
| 521 | } | 534 | } |
| 522 | 535 | ||