diff options
| author | 2017-01-04 10:53:01 -0500 | |
|---|---|---|
| committer | 2017-01-05 09:40:14 -0500 | |
| commit | fd95b6ee2606da4cd47c5f2916ad3b4f86c0e0f4 (patch) | |
| tree | 5a3d1487e24f089b68358ddd8984c12e65623055 /src/core/hle/kernel | |
| parent | Kernel: Use different thread statuses when a thread calls WaitSynchronization... (diff) | |
| download | yuzu-fd95b6ee2606da4cd47c5f2916ad3b4f86c0e0f4.tar.gz yuzu-fd95b6ee2606da4cd47c5f2916ad3b4f86c0e0f4.tar.xz yuzu-fd95b6ee2606da4cd47c5f2916ad3b4f86c0e0f4.zip | |
Kernel: Remove Thread::wait_objects_index and use wait_objects to hold all the objects that a thread is waiting on.
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 8 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.h | 16 |
3 files changed, 19 insertions, 10 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 6f61d526a..955f50a9b 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -55,10 +55,16 @@ SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() { | |||
| 55 | if (ShouldWait(thread.get())) | 55 | if (ShouldWait(thread.get())) |
| 56 | continue; | 56 | continue; |
| 57 | 57 | ||
| 58 | bool ready_to_run = std::none_of(thread->wait_objects.begin(), thread->wait_objects.end(), | 58 | // A thread is ready to run if it's either in THREADSTATUS_WAIT_SYNCH_ANY or |
| 59 | // in THREADSTATUS_WAIT_SYNCH_ALL and the rest of the objects it is waiting on are ready. | ||
| 60 | bool ready_to_run = true; | ||
| 61 | if (thread->status == THREADSTATUS_WAIT_SYNCH_ALL) { | ||
| 62 | ready_to_run = std::none_of(thread->wait_objects.begin(), thread->wait_objects.end(), | ||
| 59 | [&thread](const SharedPtr<WaitObject>& object) { | 63 | [&thread](const SharedPtr<WaitObject>& object) { |
| 60 | return object->ShouldWait(thread.get()); | 64 | return object->ShouldWait(thread.get()); |
| 61 | }); | 65 | }); |
| 66 | } | ||
| 67 | |||
| 62 | if (ready_to_run) { | 68 | if (ready_to_run) { |
| 63 | candidate = thread.get(); | 69 | candidate = thread.get(); |
| 64 | candidate_priority = thread->current_priority; | 70 | candidate_priority = thread->current_priority; |
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index aa99d18c7..568cef5b9 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -579,6 +579,11 @@ void Thread::SetWaitSynchronizationOutput(s32 output) { | |||
| 579 | context.cpu_registers[1] = output; | 579 | context.cpu_registers[1] = output; |
| 580 | } | 580 | } |
| 581 | 581 | ||
| 582 | s32 Thread::GetWaitObjectIndex(WaitObject* object) const { | ||
| 583 | auto match = std::find(wait_objects.rbegin(), wait_objects.rend(), object); | ||
| 584 | return std::distance(match, wait_objects.rend()) - 1; | ||
| 585 | } | ||
| 586 | |||
| 582 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 587 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 583 | 588 | ||
| 584 | void ThreadingInit() { | 589 | void ThreadingInit() { |
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 6cd8c20e2..af72b76ea 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -135,13 +135,14 @@ public: | |||
| 135 | 135 | ||
| 136 | /** | 136 | /** |
| 137 | * Retrieves the index that this particular object occupies in the list of objects | 137 | * Retrieves the index that this particular object occupies in the list of objects |
| 138 | * that the thread passed to WaitSynchronizationN. | 138 | * that the thread passed to WaitSynchronizationN, starting the search from the last element. |
| 139 | * It is used to set the output value of WaitSynchronizationN when the thread is awakened. | 139 | * It is used to set the output value of WaitSynchronizationN when the thread is awakened. |
| 140 | * When a thread wakes up due to an object signal, the kernel will use the index of the last | ||
| 141 | * matching object in the wait objects list in case of having multiple instances of the same | ||
| 142 | * object in the list. | ||
| 140 | * @param object Object to query the index of. | 143 | * @param object Object to query the index of. |
| 141 | */ | 144 | */ |
| 142 | s32 GetWaitObjectIndex(const WaitObject* object) const { | 145 | s32 GetWaitObjectIndex(WaitObject* object) const; |
| 143 | return wait_objects_index.at(object->GetObjectId()); | ||
| 144 | } | ||
| 145 | 146 | ||
| 146 | /** | 147 | /** |
| 147 | * Stops a thread, invalidating it from further use | 148 | * Stops a thread, invalidating it from further use |
| @@ -190,13 +191,10 @@ public: | |||
| 190 | 191 | ||
| 191 | SharedPtr<Process> owner_process; ///< Process that owns this thread | 192 | SharedPtr<Process> owner_process; ///< Process that owns this thread |
| 192 | 193 | ||
| 193 | /// Objects that the thread is waiting on. | 194 | /// Objects that the thread is waiting on, in the same order as they were |
| 194 | /// This is only populated when the thread should wait for all the objects to become ready. | 195 | // passed to WaitSynchronization1/N. |
| 195 | std::vector<SharedPtr<WaitObject>> wait_objects; | 196 | std::vector<SharedPtr<WaitObject>> wait_objects; |
| 196 | 197 | ||
| 197 | /// Mapping of Object ids to their position in the last waitlist that this object waited on. | ||
| 198 | boost::container::flat_map<int, s32> wait_objects_index; | ||
| 199 | |||
| 200 | VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address | 198 | VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address |
| 201 | 199 | ||
| 202 | /// True if the WaitSynchronizationN output parameter should be set on thread wakeup. | 200 | /// True if the WaitSynchronizationN output parameter should be set on thread wakeup. |