Kernel: Preempt Single core on redudant yields.

This commit is contained in:
Fernando Sahmkow 2020-03-10 13:13:39 -04:00
parent a439cdf22e
commit d494b074e8
6 changed files with 42 additions and 21 deletions

View file

@ -19,6 +19,7 @@
#include "core/core_manager.h"
#include "core/core_timing.h"
#include "core/core_timing_util.h"
#include "core/cpu_manager.h"
#include "core/hle/kernel/address_arbiter.h"
#include "core/hle/kernel/client_port.h"
#include "core/hle/kernel/client_session.h"
@ -1509,21 +1510,31 @@ static void SleepThread(Core::System& system, s64 nanoseconds) {
if (nanoseconds <= 0) {
switch (static_cast<SleepType>(nanoseconds)) {
case SleepType::YieldWithoutLoadBalancing:
current_thread->YieldSimple();
case SleepType::YieldWithoutLoadBalancing: {
auto pair = current_thread->YieldSimple();
is_redundant = pair.second;
break;
case SleepType::YieldWithLoadBalancing:
current_thread->YieldAndBalanceLoad();
}
case SleepType::YieldWithLoadBalancing: {
auto pair = current_thread->YieldAndBalanceLoad();
is_redundant = pair.second;
break;
case SleepType::YieldAndWaitForLoadBalancing:
current_thread->YieldAndWaitForLoadBalancing();
}
case SleepType::YieldAndWaitForLoadBalancing: {
auto pair = current_thread->YieldAndWaitForLoadBalancing();
is_redundant = pair.second;
break;
}
default:
UNREACHABLE_MSG("Unimplemented sleep yield type '{:016X}'!", nanoseconds);
}
} else {
current_thread->Sleep(nanoseconds);
}
if (is_redundant && !system.Kernel().IsMulticore()) {
system.GetCpuManager().PreemptSingleCore();
}
}
/// Wait process wide key atomic