Browse Source

kernel/thread: Expand documentation of nominal_priority and current_priority

Aims to disambiguate why each priority instance exists a little bit.
While we're at it, also add an explanatory comment to UpdatePriority().
Lioncash 7 years ago
parent
commit
db47d7e471
2 changed files with 11 additions and 3 deletions
  1. 3 1
      src/core/hle/kernel/thread.cpp
  2. 8 2
      src/core/hle/kernel/thread.h

+ 3 - 1
src/core/hle/kernel/thread.cpp

@@ -303,7 +303,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
+    // If any of the threads waiting on the mutex have a higher priority
+    // (taking into account priority inheritance), then this thread inherits
+    // that thread's priority.
     u32 new_priority = nominal_priority;
     u32 new_priority = nominal_priority;
     if (!wait_mutex_threads.empty()) {
     if (!wait_mutex_threads.empty()) {
         if (wait_mutex_threads.front()->current_priority < new_priority) {
         if (wait_mutex_threads.front()->current_priority < new_priority) {

+ 8 - 2
src/core/hle/kernel/thread.h

@@ -398,8 +398,14 @@ private:
     VAddr entry_point = 0;
     VAddr entry_point = 0;
     VAddr stack_top = 0;
     VAddr stack_top = 0;
 
 
-    u32 nominal_priority = 0; ///< Nominal thread priority, as set by the emulated application
-    u32 current_priority = 0; ///< Current thread priority, can be temporarily changed
+    /// Nominal thread priority, as set by the emulated application.
+    /// The nominal priority is the thread priority without priority
+    /// inheritance taken into account.
+    u32 nominal_priority = 0;
+
+    /// Current thread priority. This may change over the course of the
+    /// thread's lifetime in order to facilitate priority inheritance.
+    u32 current_priority = 0;
 
 
     u64 total_cpu_time_ticks = 0; ///< Total CPU running ticks.
     u64 total_cpu_time_ticks = 0; ///< Total CPU running ticks.
     u64 last_running_ticks = 0;   ///< CPU tick when thread was last running
     u64 last_running_ticks = 0;   ///< CPU tick when thread was last running