summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2017-01-03 01:38:08 +0100
committerSubv <subv2112@gmail.com>2017-01-04 21:58:48 +0100
commitd3ff5b91e14356912589f9bac47fccbe79e07279 (patch)
treee35c698d40539e360981a61b38f8fbb60aee7418 /src/core/hle/kernel/thread.cpp
parentKernel/Mutex: Update a mutex priority when a thread stops waiting on it. (diff)
downloadyuzu-d3ff5b91e14356912589f9bac47fccbe79e07279.tar
yuzu-d3ff5b91e14356912589f9bac47fccbe79e07279.tar.gz
yuzu-d3ff5b91e14356912589f9bac47fccbe79e07279.tar.bz2
yuzu-d3ff5b91e14356912589f9bac47fccbe79e07279.tar.lz
yuzu-d3ff5b91e14356912589f9bac47fccbe79e07279.tar.xz
yuzu-d3ff5b91e14356912589f9bac47fccbe79e07279.tar.zst
yuzu-d3ff5b91e14356912589f9bac47fccbe79e07279.zip
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp21
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() {
WakeupAllWaitingThreads();
- // Release all the mutexes that this thread holds
- ReleaseThreadMutexes(this);
-
// Clean up any dangling references in objects that this thread was waiting for
for (auto& wait_object : wait_objects) {
wait_object->RemoveWaitingThread(this);
}
wait_objects.clear();
+ // Release all the mutexes that this thread holds
+ ReleaseThreadMutexes(this);
+
// Mark the TLS slot in the thread's page as free.
u32 tls_page = (tls_address - Memory::TLS_AREA_VADDR) / Memory::PAGE_SIZE;
u32 tls_slot =
@@ -515,8 +515,21 @@ void Thread::SetPriority(s32 priority) {
nominal_priority = current_priority = priority;
}
+void Thread::UpdatePriority() {
+ s32 best_priority = nominal_priority;
+ for (auto& mutex : held_mutexes) {
+ if (mutex->priority < best_priority)
+ best_priority = mutex->priority;
+ }
+ BoostPriority(best_priority);
+}
+
void Thread::BoostPriority(s32 priority) {
- ready_queue.move(this, current_priority, priority);
+ // If thread was ready, adjust queues
+ if (status == THREADSTATUS_READY)
+ ready_queue.move(this, current_priority, priority);
+ else
+ ready_queue.prepare(priority);
current_priority = priority;
}