Compare commits

...

1 Commits

Author SHA1 Message Date
bunnei
5583fe1377 svc: Improve SleepThread for yield types.
- Fixes Super Mario Party.
2018-10-23 19:06:08 -04:00

View File

@@ -770,12 +770,24 @@ static void ExitThread() {
/// Sleep the current thread
static void SleepThread(s64 nanoseconds) {
LOG_TRACE(Kernel_SVC, "called nanoseconds={}", nanoseconds);
LOG_DEBUG(Kernel_SVC, "called nanoseconds={}", nanoseconds);
// 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.
if (nanoseconds == 0 && !Core::System::GetInstance().CurrentScheduler().HaveReadyThreads())
if (nanoseconds == 0) {
// Yield type 0 is just a yield without load balancing
Core::System::GetInstance().CpuCore(0).PrepareReschedule();
Core::System::GetInstance().CpuCore(1).PrepareReschedule();
Core::System::GetInstance().CpuCore(2).PrepareReschedule();
Core::System::GetInstance().CpuCore(3).PrepareReschedule();
return;
}
if (nanoseconds < 0) {
UNIMPLEMENTED_MSG("unimplemented yield type");
// TODO(bunnei): Implement the various load balancing yield types here. This will force a
// reschedule, but is incorrect.
nanoseconds = 0;
}
// Sleep current thread and check for next thread to schedule
WaitCurrentThread_Sleep();
@@ -783,7 +795,10 @@ static void SleepThread(s64 nanoseconds) {
// Create an event to wake the thread up after the specified nanosecond delay has passed
GetCurrentThread()->WakeAfterDelay(nanoseconds);
Core::System::GetInstance().PrepareReschedule();
Core::System::GetInstance().CpuCore(0).PrepareReschedule();
Core::System::GetInstance().CpuCore(1).PrepareReschedule();
Core::System::GetInstance().CpuCore(2).PrepareReschedule();
Core::System::GetInstance().CpuCore(3).PrepareReschedule();
}
/// Wait process wide key atomic