svc: Avoid performance-degrading unnecessary reschedule

This commit is contained in:
Zach Hilman 2018-12-02 00:44:40 -05:00
parent 820d81b9a5
commit 3476830b26
2 changed files with 6 additions and 8 deletions

View File

@ -207,8 +207,8 @@ void Scheduler::YieldWithoutLoadBalancing(Thread* thread) {
ASSERT(thread->GetPriority() < THREADPRIO_COUNT); ASSERT(thread->GetPriority() < THREADPRIO_COUNT);
// Yield this thread // Yield this thread
MoveThreadToBackOfPriorityQueue(thread, thread->GetPriority());
Reschedule(); Reschedule();
MoveThreadToBackOfPriorityQueue(thread, thread->GetPriority());
} }
void Scheduler::YieldWithLoadBalancing(Thread* thread) { void Scheduler::YieldWithLoadBalancing(Thread* thread) {
@ -223,6 +223,7 @@ void Scheduler::YieldWithLoadBalancing(Thread* thread) {
ASSERT(priority < THREADPRIO_COUNT); ASSERT(priority < THREADPRIO_COUNT);
// Reschedule thread to end of queue. // Reschedule thread to end of queue.
Reschedule();
MoveThreadToBackOfPriorityQueue(thread, priority); MoveThreadToBackOfPriorityQueue(thread, priority);
Thread* suggested_thread = nullptr; Thread* suggested_thread = nullptr;

View File

@ -962,13 +962,13 @@ static void SleepThread(s64 nanoseconds) {
// Don't attempt to yield execution if there are no available threads to run, // Don't attempt to yield execution if there are no available threads to run,
// this way we avoid a useless reschedule to the idle thread. // this way we avoid a useless reschedule to the idle thread.
if (!Core::System::GetInstance().CurrentScheduler().HaveReadyThreads()) if (nanoseconds <= 0 && !Core::System::GetInstance().CurrentScheduler().HaveReadyThreads())
return; return;
enum class SleepType : s64 { enum class SleepType : s64 {
YieldWithoutLoadBalancing = 0, YieldWithoutLoadBalancing = 0,
YieldWithLoadBalancing = 1, YieldWithLoadBalancing = -1,
YieldAndWaitForLoadBalancing = 2, YieldAndWaitForLoadBalancing = -2,
}; };
if (nanoseconds <= 0) { if (nanoseconds <= 0) {
@ -998,10 +998,7 @@ static void SleepThread(s64 nanoseconds) {
// Create an event to wake the thread up after the specified nanosecond delay has passed // Create an event to wake the thread up after the specified nanosecond delay has passed
GetCurrentThread()->WakeAfterDelay(nanoseconds); GetCurrentThread()->WakeAfterDelay(nanoseconds);
Core::System::GetInstance().CpuCore(0).PrepareReschedule(); Core::System::GetInstance().PrepareReschedule();
Core::System::GetInstance().CpuCore(1).PrepareReschedule();
Core::System::GetInstance().CpuCore(2).PrepareReschedule();
Core::System::GetInstance().CpuCore(3).PrepareReschedule();
} }
/// Wait process wide key atomic /// Wait process wide key atomic