summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.h
diff options
context:
space:
mode:
authorGravatar Lioncash2019-04-17 07:21:19 -0400
committerGravatar Lioncash2019-04-17 09:30:56 -0400
commitc268ffd831bc8771585934e7e24da0f7e150936e (patch)
treeee35a6da18561f3b3d7a43a37081f7f175e62314 /src/core/hle/kernel/thread.h
parentkernel/svc: Migrate svcCancelSynchronization behavior to a thread function (diff)
downloadyuzu-c268ffd831bc8771585934e7e24da0f7e150936e.tar.gz
yuzu-c268ffd831bc8771585934e7e24da0f7e150936e.tar.xz
yuzu-c268ffd831bc8771585934e7e24da0f7e150936e.zip
kernel/thread: Unify wait synchronization types
This is a holdover from Citra, where the 3DS has both WaitSynchronization1 and WaitSynchronizationN. The switch only has one form of wait synchronizing (literally WaitSynchonization). This allows us to throw out code that doesn't apply at all to the Switch kernel. Because of this unnecessary dichotomy within the wait synchronization utilities, we were also neglecting to properly handle waiting on multiple objects. While we're at it, we can also scrub out any lingering references to WaitSynchronization1/WaitSynchronizationN in comments, and change them to WaitSynchronization (or remove them if the mention no longer applies).
Diffstat (limited to 'src/core/hle/kernel/thread.h')
-rw-r--r--src/core/hle/kernel/thread.h28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index e3c457408..62ce7bfda 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
@@ -185,24 +184,27 @@ public:
185 void CancelWakeupTimer(); 184 void CancelWakeupTimer();
186 185
187 /** 186 /**
188 * Sets the result after the thread awakens (from either WaitSynchronization SVC) 187 * Sets the result after the thread awakens (from svcWaitSynchronization)
189 * @param result Value to set to the returned result 188 * @param result Value to set to the returned result
190 */ 189 */
191 void SetWaitSynchronizationResult(ResultCode result); 190 void SetWaitSynchronizationResult(ResultCode result);
192 191
193 /** 192 /**
194 * Sets the output parameter value after the thread awakens (from WaitSynchronizationN SVC only) 193 * Sets the output parameter value after the thread awakens (from svcWaitSynchronization)
195 * @param output Value to set to the output parameter 194 * @param output Value to set to the output parameter
196 */ 195 */
197 void SetWaitSynchronizationOutput(s32 output); 196 void SetWaitSynchronizationOutput(s32 output);
198 197
199 /** 198 /**
200 * Retrieves the index that this particular object occupies in the list of objects 199 * Retrieves the index that this particular object occupies in the list of objects
201 * that the thread passed to WaitSynchronizationN, starting the search from the last element. 200 * that the thread passed to WaitSynchronization, starting the search from the last element.
202 * It is used to set the output value of WaitSynchronizationN when the thread is awakened. 201 *
202 * It is used to set the output index of WaitSynchronization when the thread is awakened.
203 *
203 * When a thread wakes up due to an object signal, the kernel will use the index of the last 204 * When a thread wakes up due to an object signal, the kernel will use the index of the last
204 * matching object in the wait objects list in case of having multiple instances of the same 205 * matching object in the wait objects list in case of having multiple instances of the same
205 * object in the list. 206 * object in the list.
207 *
206 * @param object Object to query the index of. 208 * @param object Object to query the index of.
207 */ 209 */
208 s32 GetWaitObjectIndex(const WaitObject* object) const; 210 s32 GetWaitObjectIndex(const WaitObject* object) const;
@@ -239,13 +241,9 @@ public:
239 */ 241 */
240 VAddr GetCommandBufferAddress() const; 242 VAddr GetCommandBufferAddress() const;
241 243
242 /** 244 /// Returns whether this thread is waiting on objects from a WaitSynchronization call.
243 * Returns whether this thread is waiting for all the objects in 245 bool IsSleepingOnWait() const {
244 * its wait list to become ready, as a result of a WaitSynchronizationN call 246 return status == ThreadStatus::WaitSynch;
245 * with wait_all = true.
246 */
247 bool IsSleepingOnWaitAll() const {
248 return status == ThreadStatus::WaitSynchAll;
249 } 247 }
250 248
251 ThreadContext& GetContext() { 249 ThreadContext& GetContext() {
@@ -423,7 +421,7 @@ private:
423 Process* owner_process; 421 Process* owner_process;
424 422
425 /// Objects that the thread is waiting on, in the same order as they were 423 /// Objects that the thread is waiting on, in the same order as they were
426 /// passed to WaitSynchronization1/N. 424 /// passed to WaitSynchronization.
427 ThreadWaitObjects wait_objects; 425 ThreadWaitObjects wait_objects;
428 426
429 /// List of threads that are waiting for a mutex that is held by this thread. 427 /// List of threads that are waiting for a mutex that is held by this thread.
@@ -449,7 +447,7 @@ private:
449 Handle callback_handle = 0; 447 Handle callback_handle = 0;
450 448
451 /// Callback that will be invoked when the thread is resumed from a waiting state. If the thread 449 /// Callback that will be invoked when the thread is resumed from a waiting state. If the thread
452 /// was waiting via WaitSynchronizationN then the object will be the last object that became 450 /// was waiting via WaitSynchronization then the object will be the last object that became
453 /// available. In case of a timeout, the object will be nullptr. 451 /// available. In case of a timeout, the object will be nullptr.
454 WakeupCallback wakeup_callback; 452 WakeupCallback wakeup_callback;
455 453