summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/scheduler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/scheduler.cpp')
-rw-r--r--src/core/hle/kernel/scheduler.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp
index c6b7d5232..df4d6cf0a 100644
--- a/src/core/hle/kernel/scheduler.cpp
+++ b/src/core/hle/kernel/scheduler.cpp
@@ -200,7 +200,6 @@ void Scheduler::YieldWithoutLoadBalancing(Thread* thread) {
200 // Yield this thread -- sleep for zero time and force reschedule to different thread 200 // Yield this thread -- sleep for zero time and force reschedule to different thread
201 WaitCurrentThread_Sleep(); 201 WaitCurrentThread_Sleep();
202 GetCurrentThread()->WakeAfterDelay(0); 202 GetCurrentThread()->WakeAfterDelay(0);
203 Reschedule();
204} 203}
205 204
206void Scheduler::YieldWithLoadBalancing(Thread* thread) { 205void Scheduler::YieldWithLoadBalancing(Thread* thread) {
@@ -223,24 +222,23 @@ void Scheduler::YieldWithLoadBalancing(Thread* thread) {
223 // Search through all of the cpu cores (except this one) for a suggested thread. 222 // Search through all of the cpu cores (except this one) for a suggested thread.
224 // Take the first non-nullptr one 223 // Take the first non-nullptr one
225 for (unsigned cur_core = 0; cur_core < Core::NUM_CPU_CORES; ++cur_core) { 224 for (unsigned cur_core = 0; cur_core < Core::NUM_CPU_CORES; ++cur_core) {
226 if (cur_core == core)
227 continue;
228
229 const auto res = 225 const auto res =
230 Core::System::GetInstance().CpuCore(cur_core).Scheduler().GetNextSuggestedThread( 226 Core::System::GetInstance().CpuCore(cur_core).Scheduler().GetNextSuggestedThread(
231 core, priority); 227 core, priority);
232 if (res != nullptr && 228
233 (suggested_thread == nullptr || suggested_thread->GetPriority() > res->GetPriority())) { 229 // If scheduler provides a suggested thread
234 suggested_thread = res; 230 if (res != nullptr) {
231 // And its better than the current suggested thread (or is the first valid one)
232 if (suggested_thread == nullptr ||
233 suggested_thread->GetPriority() > res->GetPriority()) {
234 suggested_thread = res;
235 }
235 } 236 }
236 } 237 }
237 238
238 // If a suggested thread was found, queue that for this core 239 // If a suggested thread was found, queue that for this core
239 if (suggested_thread != nullptr) 240 if (suggested_thread != nullptr)
240 suggested_thread->ChangeCore(core, suggested_thread->GetAffinityMask()); 241 suggested_thread->ChangeCore(core, suggested_thread->GetAffinityMask());
241
242 // Perform actual yielding.
243 Reschedule();
244} 242}
245 243
246void Scheduler::YieldAndWaitForLoadBalancing(Thread* thread) { 244void Scheduler::YieldAndWaitForLoadBalancing(Thread* thread) {