summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-11-22 00:33:53 -0500
committerGravatar Zach Hilman2018-11-22 00:33:53 -0500
commit820d81b9a5392951c18daa5a47d6c0ffd28baa9b (patch)
treedab20f1ff49ab76cdcd511e189799f4d6e40677e /src/core/hle/kernel/thread.cpp
parentsvc: Implement yield types 0 and -1 (diff)
downloadyuzu-820d81b9a5392951c18daa5a47d6c0ffd28baa9b.tar.gz
yuzu-820d81b9a5392951c18daa5a47d6c0ffd28baa9b.tar.xz
yuzu-820d81b9a5392951c18daa5a47d6c0ffd28baa9b.zip
scheduler: Add explanations for YieldWith and WithoutLoadBalancing
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp60
1 files changed, 0 insertions, 60 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index ddc4da1c0..4ffb76818 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -388,66 +388,6 @@ bool Thread::InvokeWakeupCallback(ThreadWakeupReason reason, SharedPtr<Thread> t
388 return wakeup_callback(reason, std::move(thread), std::move(object), index); 388 return wakeup_callback(reason, std::move(thread), std::move(object), index);
389} 389}
390 390
391void Thread::YieldNormal() {
392 // Avoid yielding if the thread isn't even running.
393 if (status != ThreadStatus::Running) {
394 return;
395 }
396
397 if (nominal_priority < THREADPRIO_COUNT) {
398 scheduler->RescheduleThread(this, nominal_priority);
399 scheduler->Reschedule();
400 }
401}
402
403void Thread::YieldWithLoadBalancing() {
404 auto priority = nominal_priority;
405 auto core = processor_id;
406
407 // Avoid yielding if the thread isn't even running.
408 if (status != ThreadStatus::Running) {
409 Core::System::GetInstance().CpuCore(processor_id).PrepareReschedule();
410 return;
411 }
412
413 SharedPtr<Thread> next;
414 const auto& threads = scheduler->GetThreadList();
415
416 if (priority < THREADPRIO_COUNT) {
417 // Reschedule thread to end of queue.
418 scheduler->RescheduleThread(this, priority);
419
420 const auto iter = std::find_if(threads.begin(), threads.end(),
421 [&priority](const SharedPtr<Thread>& thread) {
422 return thread->GetNominalPriority() == priority;
423 });
424
425 if (iter != threads.end())
426 next = iter->get();
427 }
428
429 Thread* suggested_thread = nullptr;
430
431 for (int i = 0; i < 4; ++i) {
432 if (i == core)
433 continue;
434
435 const auto res =
436 Core::System::GetInstance().CpuCore(i).Scheduler().GetNextSuggestedThread(core);
437 if (res != nullptr) {
438 suggested_thread = res;
439 break;
440 }
441 }
442
443 if (suggested_thread != nullptr)
444 suggested_thread->ChangeCore(core, suggested_thread->GetAffinityMask());
445}
446
447void Thread::YieldAndWaitForLoadBalancing() {
448 UNIMPLEMENTED_MSG("Wait for load balancing thread yield type is not implemented!");
449}
450
451//////////////////////////////////////////////////////////////////////////////////////////////////// 391////////////////////////////////////////////////////////////////////////////////////////////////////
452 392
453/** 393/**