diff options
| author | 2018-04-20 20:15:16 -0500 | |
|---|---|---|
| committer | 2018-04-23 11:23:44 -0500 | |
| commit | 46572d027dc9620ed2b2a50277e6afd2a115ab81 (patch) | |
| tree | 72562a37575252e8f4c0160a3067b415027fdf4b /src/core/hle/kernel/thread.h | |
| parent | Kernel: Use 0x2C as default main thread priority for homebrew and lone NRO/NSOs (diff) | |
| download | yuzu-46572d027dc9620ed2b2a50277e6afd2a115ab81.tar.gz yuzu-46572d027dc9620ed2b2a50277e6afd2a115ab81.tar.xz yuzu-46572d027dc9620ed2b2a50277e6afd2a115ab81.zip | |
Kernel: Implemented mutex priority inheritance.
Verified with a hwtest and implemented based on reverse engineering.
Thread A's priority will get bumped to the highest priority among all the threads that are waiting for a mutex that A holds.
Once A releases the mutex and ownership is transferred to B, A's priority will return to normal and B's priority will be bumped.
Diffstat (limited to 'src/core/hle/kernel/thread.h')
| -rw-r--r-- | src/core/hle/kernel/thread.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 0e0eae28d..e0a3c0934 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -109,6 +109,15 @@ public: | |||
| 109 | */ | 109 | */ |
| 110 | void BoostPriority(u32 priority); | 110 | void BoostPriority(u32 priority); |
| 111 | 111 | ||
| 112 | /// Adds a thread to the list of threads that are waiting for a lock held by this thread. | ||
| 113 | void AddMutexWaiter(SharedPtr<Thread> thread); | ||
| 114 | |||
| 115 | /// Removes a thread from the list of threads that are waiting for a lock held by this thread. | ||
| 116 | void RemoveMutexWaiter(SharedPtr<Thread> thread); | ||
| 117 | |||
| 118 | /// Recalculates the current priority taking into account priority inheritance. | ||
| 119 | void UpdatePriority(); | ||
| 120 | |||
| 112 | /** | 121 | /** |
| 113 | * Gets the thread's thread ID | 122 | * Gets the thread's thread ID |
| 114 | * @return The thread's ID | 123 | * @return The thread's ID |
| @@ -205,6 +214,12 @@ public: | |||
| 205 | // passed to WaitSynchronization1/N. | 214 | // passed to WaitSynchronization1/N. |
| 206 | std::vector<SharedPtr<WaitObject>> wait_objects; | 215 | std::vector<SharedPtr<WaitObject>> wait_objects; |
| 207 | 216 | ||
| 217 | /// List of threads that are waiting for a mutex that is held by this thread. | ||
| 218 | std::vector<SharedPtr<Thread>> wait_mutex_threads; | ||
| 219 | |||
| 220 | /// Thread that owns the lock that this thread is waiting for. | ||
| 221 | SharedPtr<Thread> lock_owner; | ||
| 222 | |||
| 208 | // If waiting on a ConditionVariable, this is the ConditionVariable address | 223 | // If waiting on a ConditionVariable, this is the ConditionVariable address |
| 209 | VAddr condvar_wait_address; | 224 | VAddr condvar_wait_address; |
| 210 | VAddr mutex_wait_address; ///< If waiting on a Mutex, this is the mutex address | 225 | VAddr mutex_wait_address; ///< If waiting on a Mutex, this is the mutex address |