summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/scheduler.cpp18
-rw-r--r--src/core/hle/kernel/svc.cpp4
2 files changed, 11 insertions, 11 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) {
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index fabdedd3d..29c2c2d03 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -994,7 +994,9 @@ static void SleepThread(s64 nanoseconds) {
994 GetCurrentThread()->WakeAfterDelay(nanoseconds); 994 GetCurrentThread()->WakeAfterDelay(nanoseconds);
995 } 995 }
996 996
997 Core::System::GetInstance().PrepareReschedule(); 997 // Reschedule all CPU cores
998 for (std::size_t i = 0; i < 4; ++i)
999 Core::System::GetInstance().CpuCore(i).PrepareReschedule();
998} 1000}
999 1001
1000/// Wait process wide key atomic 1002/// Wait process wide key atomic