diff options
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/address_arbiter.cpp | 28 | ||||
| -rw-r--r-- | src/core/hle/kernel/mutex.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/wait_object.cpp | 4 |
3 files changed, 18 insertions, 16 deletions
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp index c8842410b..77f7bb451 100644 --- a/src/core/hle/kernel/address_arbiter.cpp +++ b/src/core/hle/kernel/address_arbiter.cpp | |||
| @@ -22,6 +22,8 @@ namespace Kernel { | |||
| 22 | namespace { | 22 | namespace { |
| 23 | // Wake up num_to_wake (or all) threads in a vector. | 23 | // Wake up num_to_wake (or all) threads in a vector. |
| 24 | void WakeThreads(const std::vector<SharedPtr<Thread>>& waiting_threads, s32 num_to_wake) { | 24 | void WakeThreads(const std::vector<SharedPtr<Thread>>& waiting_threads, s32 num_to_wake) { |
| 25 | |||
| 26 | auto& system = Core::System::GetInstance(); | ||
| 25 | // Only process up to 'target' threads, unless 'target' is <= 0, in which case process | 27 | // Only process up to 'target' threads, unless 'target' is <= 0, in which case process |
| 26 | // them all. | 28 | // them all. |
| 27 | std::size_t last = waiting_threads.size(); | 29 | std::size_t last = waiting_threads.size(); |
| @@ -35,6 +37,8 @@ void WakeThreads(const std::vector<SharedPtr<Thread>>& waiting_threads, s32 num_ | |||
| 35 | waiting_threads[i]->SetWaitSynchronizationResult(RESULT_SUCCESS); | 37 | waiting_threads[i]->SetWaitSynchronizationResult(RESULT_SUCCESS); |
| 36 | waiting_threads[i]->SetArbiterWaitAddress(0); | 38 | waiting_threads[i]->SetArbiterWaitAddress(0); |
| 37 | waiting_threads[i]->ResumeFromWait(); | 39 | waiting_threads[i]->ResumeFromWait(); |
| 40 | if (waiting_threads[i]->GetProcessorID() >= 0) | ||
| 41 | system.CpuCore(waiting_threads[i]->GetProcessorID()).PrepareReschedule(); | ||
| 38 | } | 42 | } |
| 39 | } | 43 | } |
| 40 | } // Anonymous namespace | 44 | } // Anonymous namespace |
| @@ -174,25 +178,17 @@ ResultCode AddressArbiter::WaitForAddressImpl(VAddr address, s64 timeout) { | |||
| 174 | } | 178 | } |
| 175 | 179 | ||
| 176 | std::vector<SharedPtr<Thread>> AddressArbiter::GetThreadsWaitingOnAddress(VAddr address) const { | 180 | std::vector<SharedPtr<Thread>> AddressArbiter::GetThreadsWaitingOnAddress(VAddr address) const { |
| 177 | const auto RetrieveWaitingThreads = [this](std::size_t core_index, | ||
| 178 | std::vector<SharedPtr<Thread>>& waiting_threads, | ||
| 179 | VAddr arb_addr) { | ||
| 180 | const auto& scheduler = system.Scheduler(core_index); | ||
| 181 | const auto& thread_list = scheduler.GetThreadList(); | ||
| 182 | |||
| 183 | for (const auto& thread : thread_list) { | ||
| 184 | if (thread->GetArbiterWaitAddress() == arb_addr) { | ||
| 185 | waiting_threads.push_back(thread); | ||
| 186 | } | ||
| 187 | } | ||
| 188 | }; | ||
| 189 | 181 | ||
| 190 | // Retrieve all threads that are waiting for this address. | 182 | // Retrieve all threads that are waiting for this address. |
| 191 | std::vector<SharedPtr<Thread>> threads; | 183 | std::vector<SharedPtr<Thread>> threads; |
| 192 | RetrieveWaitingThreads(0, threads, address); | 184 | const auto& scheduler = system.GlobalScheduler(); |
| 193 | RetrieveWaitingThreads(1, threads, address); | 185 | const auto& thread_list = scheduler.GetThreadList(); |
| 194 | RetrieveWaitingThreads(2, threads, address); | 186 | |
| 195 | RetrieveWaitingThreads(3, threads, address); | 187 | for (const auto& thread : thread_list) { |
| 188 | if (thread->GetArbiterWaitAddress() == address) { | ||
| 189 | threads.push_back(thread); | ||
| 190 | } | ||
| 191 | } | ||
| 196 | 192 | ||
| 197 | // Sort them by priority, such that the highest priority ones come first. | 193 | // Sort them by priority, such that the highest priority ones come first. |
| 198 | std::sort(threads.begin(), threads.end(), | 194 | std::sort(threads.begin(), threads.end(), |
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index 98e87313b..57f2d8bf3 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp | |||
| @@ -140,6 +140,8 @@ ResultCode Mutex::Release(VAddr address) { | |||
| 140 | thread->SetMutexWaitAddress(0); | 140 | thread->SetMutexWaitAddress(0); |
| 141 | thread->SetWaitHandle(0); | 141 | thread->SetWaitHandle(0); |
| 142 | 142 | ||
| 143 | Core::System::GetInstance().PrepareReschedule(); | ||
| 144 | |||
| 143 | return RESULT_SUCCESS; | 145 | return RESULT_SUCCESS; |
| 144 | } | 146 | } |
| 145 | } // namespace Kernel | 147 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/wait_object.cpp b/src/core/hle/kernel/wait_object.cpp index 0e96ba872..e035a67e9 100644 --- a/src/core/hle/kernel/wait_object.cpp +++ b/src/core/hle/kernel/wait_object.cpp | |||
| @@ -6,6 +6,8 @@ | |||
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 9 | #include "core/core.h" | ||
| 10 | #include "core/core_cpu.h" | ||
| 9 | #include "core/hle/kernel/object.h" | 11 | #include "core/hle/kernel/object.h" |
| 10 | #include "core/hle/kernel/process.h" | 12 | #include "core/hle/kernel/process.h" |
| 11 | #include "core/hle/kernel/thread.h" | 13 | #include "core/hle/kernel/thread.h" |
| @@ -95,6 +97,8 @@ void WaitObject::WakeupWaitingThread(SharedPtr<Thread> thread) { | |||
| 95 | } | 97 | } |
| 96 | if (resume) { | 98 | if (resume) { |
| 97 | thread->ResumeFromWait(); | 99 | thread->ResumeFromWait(); |
| 100 | if (thread->GetProcessorID() >= 0) | ||
| 101 | Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); | ||
| 98 | } | 102 | } |
| 99 | } | 103 | } |
| 100 | 104 | ||