diff options
| author | 2019-04-24 22:56:08 -0400 | |
|---|---|---|
| committer | 2019-04-24 22:56:08 -0400 | |
| commit | 78574e7a470a29e7ef0c1cc062d334d133c60830 (patch) | |
| tree | 9027d3466f0f588c5f14af0e23c7f7b128c79330 /src/core/hle/kernel/thread.h | |
| parent | Merge pull request #2424 from FernandoS27/compat (diff) | |
| parent | kernel/thread: Unify wait synchronization types (diff) | |
| download | yuzu-78574e7a470a29e7ef0c1cc062d334d133c60830.tar.gz yuzu-78574e7a470a29e7ef0c1cc062d334d133c60830.tar.xz yuzu-78574e7a470a29e7ef0c1cc062d334d133c60830.zip | |
Merge pull request #2416 from lioncash/wait
kernel/svc: Clean up wait synchronization related functionality
Diffstat (limited to 'src/core/hle/kernel/thread.h')
| -rw-r--r-- | src/core/hle/kernel/thread.h | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 411a73b49..f07332f02 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -49,8 +49,7 @@ enum class ThreadStatus { | |||
| 49 | WaitHLEEvent, ///< Waiting for hle event to finish | 49 | WaitHLEEvent, ///< Waiting for hle event to finish |
| 50 | WaitSleep, ///< Waiting due to a SleepThread SVC | 50 | WaitSleep, ///< Waiting due to a SleepThread SVC |
| 51 | WaitIPC, ///< Waiting for the reply from an IPC request | 51 | WaitIPC, ///< Waiting for the reply from an IPC request |
| 52 | WaitSynchAny, ///< Waiting due to WaitSynch1 or WaitSynchN with wait_all = false | 52 | WaitSynch, ///< Waiting due to WaitSynchronization |
| 53 | WaitSynchAll, ///< Waiting due to WaitSynchronizationN with wait_all = true | ||
| 54 | WaitMutex, ///< Waiting due to an ArbitrateLock svc | 53 | WaitMutex, ///< Waiting due to an ArbitrateLock svc |
| 55 | WaitCondVar, ///< Waiting due to an WaitProcessWideKey svc | 54 | WaitCondVar, ///< Waiting due to an WaitProcessWideKey svc |
| 56 | WaitArb, ///< Waiting due to a SignalToAddress/WaitForAddress svc | 55 | WaitArb, ///< Waiting due to a SignalToAddress/WaitForAddress svc |
| @@ -169,11 +168,17 @@ public: | |||
| 169 | return tls_memory; | 168 | return tls_memory; |
| 170 | } | 169 | } |
| 171 | 170 | ||
| 172 | /** | 171 | /// Resumes a thread from waiting |
| 173 | * Resumes a thread from waiting | ||
| 174 | */ | ||
| 175 | void ResumeFromWait(); | 172 | void ResumeFromWait(); |
| 176 | 173 | ||
| 174 | /// Cancels a waiting operation that this thread may or may not be within. | ||
| 175 | /// | ||
| 176 | /// When the thread is within a waiting state, this will set the thread's | ||
| 177 | /// waiting result to signal a canceled wait. The function will then resume | ||
| 178 | /// this thread. | ||
| 179 | /// | ||
| 180 | void CancelWait(); | ||
| 181 | |||
| 177 | /** | 182 | /** |
| 178 | * Schedules an event to wake up the specified thread after the specified delay | 183 | * Schedules an event to wake up the specified thread after the specified delay |
| 179 | * @param nanoseconds The time this thread will be allowed to sleep for | 184 | * @param nanoseconds The time this thread will be allowed to sleep for |
| @@ -184,24 +189,27 @@ public: | |||
| 184 | void CancelWakeupTimer(); | 189 | void CancelWakeupTimer(); |
| 185 | 190 | ||
| 186 | /** | 191 | /** |
| 187 | * Sets the result after the thread awakens (from either WaitSynchronization SVC) | 192 | * Sets the result after the thread awakens (from svcWaitSynchronization) |
| 188 | * @param result Value to set to the returned result | 193 | * @param result Value to set to the returned result |
| 189 | */ | 194 | */ |
| 190 | void SetWaitSynchronizationResult(ResultCode result); | 195 | void SetWaitSynchronizationResult(ResultCode result); |
| 191 | 196 | ||
| 192 | /** | 197 | /** |
| 193 | * Sets the output parameter value after the thread awakens (from WaitSynchronizationN SVC only) | 198 | * Sets the output parameter value after the thread awakens (from svcWaitSynchronization) |
| 194 | * @param output Value to set to the output parameter | 199 | * @param output Value to set to the output parameter |
| 195 | */ | 200 | */ |
| 196 | void SetWaitSynchronizationOutput(s32 output); | 201 | void SetWaitSynchronizationOutput(s32 output); |
| 197 | 202 | ||
| 198 | /** | 203 | /** |
| 199 | * Retrieves the index that this particular object occupies in the list of objects | 204 | * Retrieves the index that this particular object occupies in the list of objects |
| 200 | * that the thread passed to WaitSynchronizationN, starting the search from the last element. | 205 | * that the thread passed to WaitSynchronization, starting the search from the last element. |
| 201 | * It is used to set the output value of WaitSynchronizationN when the thread is awakened. | 206 | * |
| 207 | * It is used to set the output index of WaitSynchronization when the thread is awakened. | ||
| 208 | * | ||
| 202 | * When a thread wakes up due to an object signal, the kernel will use the index of the last | 209 | * When a thread wakes up due to an object signal, the kernel will use the index of the last |
| 203 | * matching object in the wait objects list in case of having multiple instances of the same | 210 | * matching object in the wait objects list in case of having multiple instances of the same |
| 204 | * object in the list. | 211 | * object in the list. |
| 212 | * | ||
| 205 | * @param object Object to query the index of. | 213 | * @param object Object to query the index of. |
| 206 | */ | 214 | */ |
| 207 | s32 GetWaitObjectIndex(const WaitObject* object) const; | 215 | s32 GetWaitObjectIndex(const WaitObject* object) const; |
| @@ -238,13 +246,9 @@ public: | |||
| 238 | */ | 246 | */ |
| 239 | VAddr GetCommandBufferAddress() const; | 247 | VAddr GetCommandBufferAddress() const; |
| 240 | 248 | ||
| 241 | /** | 249 | /// Returns whether this thread is waiting on objects from a WaitSynchronization call. |
| 242 | * Returns whether this thread is waiting for all the objects in | 250 | bool IsSleepingOnWait() const { |
| 243 | * its wait list to become ready, as a result of a WaitSynchronizationN call | 251 | return status == ThreadStatus::WaitSynch; |
| 244 | * with wait_all = true. | ||
| 245 | */ | ||
| 246 | bool IsSleepingOnWaitAll() const { | ||
| 247 | return status == ThreadStatus::WaitSynchAll; | ||
| 248 | } | 252 | } |
| 249 | 253 | ||
| 250 | ThreadContext& GetContext() { | 254 | ThreadContext& GetContext() { |
| @@ -418,7 +422,7 @@ private: | |||
| 418 | Process* owner_process; | 422 | Process* owner_process; |
| 419 | 423 | ||
| 420 | /// Objects that the thread is waiting on, in the same order as they were | 424 | /// Objects that the thread is waiting on, in the same order as they were |
| 421 | /// passed to WaitSynchronization1/N. | 425 | /// passed to WaitSynchronization. |
| 422 | ThreadWaitObjects wait_objects; | 426 | ThreadWaitObjects wait_objects; |
| 423 | 427 | ||
| 424 | /// List of threads that are waiting for a mutex that is held by this thread. | 428 | /// List of threads that are waiting for a mutex that is held by this thread. |
| @@ -441,7 +445,7 @@ private: | |||
| 441 | Handle callback_handle = 0; | 445 | Handle callback_handle = 0; |
| 442 | 446 | ||
| 443 | /// Callback that will be invoked when the thread is resumed from a waiting state. If the thread | 447 | /// Callback that will be invoked when the thread is resumed from a waiting state. If the thread |
| 444 | /// was waiting via WaitSynchronizationN then the object will be the last object that became | 448 | /// was waiting via WaitSynchronization then the object will be the last object that became |
| 445 | /// available. In case of a timeout, the object will be nullptr. | 449 | /// available. In case of a timeout, the object will be nullptr. |
| 446 | WakeupCallback wakeup_callback; | 450 | WakeupCallback wakeup_callback; |
| 447 | 451 | ||