diff options
Diffstat (limited to 'src/core/hle/kernel/thread.h')
| -rw-r--r-- | src/core/hle/kernel/thread.h | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index dbf47e269..e0a3c0934 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -18,7 +18,7 @@ | |||
| 18 | enum ThreadPriority : u32 { | 18 | enum ThreadPriority : u32 { |
| 19 | THREADPRIO_HIGHEST = 0, ///< Highest thread priority | 19 | THREADPRIO_HIGHEST = 0, ///< Highest thread priority |
| 20 | THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps | 20 | THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps |
| 21 | THREADPRIO_DEFAULT = 48, ///< Default thread priority for userland apps | 21 | THREADPRIO_DEFAULT = 44, ///< Default thread priority for userland apps |
| 22 | THREADPRIO_LOWEST = 63, ///< Lowest thread priority | 22 | THREADPRIO_LOWEST = 63, ///< Lowest thread priority |
| 23 | }; | 23 | }; |
| 24 | 24 | ||
| @@ -43,6 +43,7 @@ enum ThreadStatus { | |||
| 43 | THREADSTATUS_WAIT_IPC, ///< Waiting for the reply from an IPC request | 43 | THREADSTATUS_WAIT_IPC, ///< Waiting for the reply from an IPC request |
| 44 | THREADSTATUS_WAIT_SYNCH_ANY, ///< Waiting due to WaitSynch1 or WaitSynchN with wait_all = false | 44 | THREADSTATUS_WAIT_SYNCH_ANY, ///< Waiting due to WaitSynch1 or WaitSynchN with wait_all = false |
| 45 | THREADSTATUS_WAIT_SYNCH_ALL, ///< Waiting due to WaitSynchronizationN with wait_all = true | 45 | THREADSTATUS_WAIT_SYNCH_ALL, ///< Waiting due to WaitSynchronizationN with wait_all = true |
| 46 | THREADSTATUS_WAIT_MUTEX, ///< Waiting due to an ArbitrateLock/WaitProcessWideKey svc | ||
| 46 | THREADSTATUS_DORMANT, ///< Created but not yet made ready | 47 | THREADSTATUS_DORMANT, ///< Created but not yet made ready |
| 47 | THREADSTATUS_DEAD ///< Run to completion, or forcefully terminated | 48 | THREADSTATUS_DEAD ///< Run to completion, or forcefully terminated |
| 48 | }; | 49 | }; |
| @@ -54,7 +55,6 @@ enum class ThreadWakeupReason { | |||
| 54 | 55 | ||
| 55 | namespace Kernel { | 56 | namespace Kernel { |
| 56 | 57 | ||
| 57 | class Mutex; | ||
| 58 | class Process; | 58 | class Process; |
| 59 | 59 | ||
| 60 | class Thread final : public WaitObject { | 60 | class Thread final : public WaitObject { |
| @@ -104,17 +104,20 @@ public: | |||
| 104 | void SetPriority(u32 priority); | 104 | void SetPriority(u32 priority); |
| 105 | 105 | ||
| 106 | /** | 106 | /** |
| 107 | * Boost's a thread's priority to the best priority among the thread's held mutexes. | ||
| 108 | * This prevents priority inversion via priority inheritance. | ||
| 109 | */ | ||
| 110 | void UpdatePriority(); | ||
| 111 | |||
| 112 | /** | ||
| 113 | * Temporarily boosts the thread's priority until the next time it is scheduled | 107 | * Temporarily boosts the thread's priority until the next time it is scheduled |
| 114 | * @param priority The new priority | 108 | * @param priority The new priority |
| 115 | */ | 109 | */ |
| 116 | void BoostPriority(u32 priority); | 110 | void BoostPriority(u32 priority); |
| 117 | 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 | |||
| 118 | /** | 121 | /** |
| 119 | * Gets the thread's thread ID | 122 | * Gets the thread's thread ID |
| 120 | * @return The thread's ID | 123 | * @return The thread's ID |
| @@ -205,19 +208,22 @@ public: | |||
| 205 | 208 | ||
| 206 | VAddr tls_address; ///< Virtual address of the Thread Local Storage of the thread | 209 | VAddr tls_address; ///< Virtual address of the Thread Local Storage of the thread |
| 207 | 210 | ||
| 208 | /// Mutexes currently held by this thread, which will be released when it exits. | ||
| 209 | boost::container::flat_set<SharedPtr<Mutex>> held_mutexes; | ||
| 210 | |||
| 211 | /// Mutexes that this thread is currently waiting for. | ||
| 212 | boost::container::flat_set<SharedPtr<Mutex>> pending_mutexes; | ||
| 213 | |||
| 214 | SharedPtr<Process> owner_process; ///< Process that owns this thread | 211 | SharedPtr<Process> owner_process; ///< Process that owns this thread |
| 215 | 212 | ||
| 216 | /// Objects that the thread is waiting on, in the same order as they were | 213 | /// Objects that the thread is waiting on, in the same order as they were |
| 217 | // passed to WaitSynchronization1/N. | 214 | // passed to WaitSynchronization1/N. |
| 218 | std::vector<SharedPtr<WaitObject>> wait_objects; | 215 | std::vector<SharedPtr<WaitObject>> wait_objects; |
| 219 | 216 | ||
| 220 | VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address | 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 | |||
| 223 | // If waiting on a ConditionVariable, this is the ConditionVariable address | ||
| 224 | VAddr condvar_wait_address; | ||
| 225 | VAddr mutex_wait_address; ///< If waiting on a Mutex, this is the mutex address | ||
| 226 | Handle wait_handle; ///< The handle used to wait for the mutex. | ||
| 221 | 227 | ||
| 222 | std::string name; | 228 | std::string name; |
| 223 | 229 | ||