diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/core.cpp | 5 | ||||
-rw-r--r-- | src/core/core.h | 3 | ||||
-rw-r--r-- | src/core/core_cpu.h | 2 | ||||
-rw-r--r-- | src/core/hle/kernel/address_arbiter.cpp | 5 | ||||
-rw-r--r-- | src/core/hle/kernel/svc.cpp | 49 | ||||
-rw-r--r-- | src/core/hle/kernel/wait_object.cpp | 3 |
6 files changed, 29 insertions, 38 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 5565840fd..4a95630bd 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -404,6 +404,11 @@ void System::PrepareReschedule() { CurrentCpuCore().PrepareReschedule(); } +void System::PrepareReschedule(s32 core_index) { + if (core_index >= 0) + CpuCore(core_index).PrepareReschedule(); +} + PerfStatsResults System::GetAndResetPerfStats() { return impl->GetAndResetPerfStats(); } diff --git a/src/core/core.h b/src/core/core.h index 2a002f6d7..0d1008895 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -185,6 +185,9 @@ public: /// Prepare the core emulation for a reschedule void PrepareReschedule(); + /// Prepare the core emulation for a reschedule + void PrepareReschedule(s32 core_index); + /// Gets and resets core performance statistics PerfStatsResults GetAndResetPerfStats(); diff --git a/src/core/core_cpu.h b/src/core/core_cpu.h index 5dde2994c..0cde54787 100644 --- a/src/core/core_cpu.h +++ b/src/core/core_cpu.h @@ -14,7 +14,7 @@ namespace Kernel { class Scheduler; class GlobalScheduler; -} +} // namespace Kernel namespace Core { class System; diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp index 77f7bb451..c66cd16ef 100644 --- a/src/core/hle/kernel/address_arbiter.cpp +++ b/src/core/hle/kernel/address_arbiter.cpp @@ -37,8 +37,7 @@ void WakeThreads(const std::vector<SharedPtr<Thread>>& waiting_threads, s32 num_ waiting_threads[i]->SetWaitSynchronizationResult(RESULT_SUCCESS); waiting_threads[i]->SetArbiterWaitAddress(0); waiting_threads[i]->ResumeFromWait(); - if (waiting_threads[i]->GetProcessorID() >= 0) - system.CpuCore(waiting_threads[i]->GetProcessorID()).PrepareReschedule(); + system.PrepareReschedule(waiting_threads[i]->GetProcessorID()); } } } // Anonymous namespace @@ -173,7 +172,7 @@ ResultCode AddressArbiter::WaitForAddressImpl(VAddr address, s64 timeout) { current_thread->WakeAfterDelay(timeout); - system.CpuCore(current_thread->GetProcessorID()).PrepareReschedule(); + system.PrepareReschedule(current_thread->GetProcessorID()); return RESULT_TIMEOUT; } diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index ee1e9f006..560ac3945 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -516,7 +516,7 @@ static ResultCode WaitSynchronization(Core::System& system, Handle* index, VAddr thread->WakeAfterDelay(nano_seconds); thread->SetWakeupCallback(DefaultThreadWakeupCallback); - system.CpuCore(thread->GetProcessorID()).PrepareReschedule(); + system.PrepareReschedule(thread->GetProcessorID()); return RESULT_TIMEOUT; } @@ -534,8 +534,7 @@ static ResultCode CancelSynchronization(Core::System& system, Handle thread_hand } thread->CancelWait(); - if (thread->GetProcessorID() >= 0) - Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); + system.PrepareReschedule(thread->GetProcessorID()); return RESULT_SUCCESS; } @@ -1069,8 +1068,7 @@ static ResultCode SetThreadActivity(Core::System& system, Handle handle, u32 act thread->SetActivity(static_cast<ThreadActivity>(activity)); - if (thread->GetProcessorID() >= 0) - Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); + system.PrepareReschedule(thread->GetProcessorID()); return RESULT_SUCCESS; } @@ -1152,8 +1150,7 @@ static ResultCode SetThreadPriority(Core::System& system, Handle handle, u32 pri thread->SetPriority(priority); - if (thread->GetProcessorID() >= 0) - Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); + system.PrepareReschedule(thread->GetProcessorID()); return RESULT_SUCCESS; } @@ -1509,8 +1506,7 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e thread->SetName( fmt::format("thread[entry_point={:X}, handle={:X}]", entry_point, *new_thread_handle)); - if (thread->GetProcessorID() >= 0) - Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); + system.PrepareReschedule(thread->GetProcessorID()); return RESULT_SUCCESS; } @@ -1532,10 +1528,7 @@ static ResultCode StartThread(Core::System& system, Handle thread_handle) { thread->ResumeFromWait(); if (thread->GetStatus() == ThreadStatus::Ready) { - if (thread->GetProcessorID() >= 0) - Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); - else - Core::System::GetInstance().GlobalScheduler().SetReselectionPending(); + system.PrepareReschedule(thread->GetProcessorID()); } return RESULT_SUCCESS; @@ -1582,10 +1575,7 @@ static void SleepThread(Core::System& system, s64 nanoseconds) { current_thread->Sleep(nanoseconds); } - // Reschedule all CPU cores - for (std::size_t i = 0; i < Core::NUM_CPU_CORES; ++i) { - system.CpuCore(i).PrepareReschedule(); - } + system.PrepareReschedule(current_thread->GetProcessorID()); } /// Wait process wide key atomic @@ -1632,7 +1622,7 @@ static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr mutex_add // Note: Deliberately don't attempt to inherit the lock owner's priority. - system.CpuCore(current_thread->GetProcessorID()).PrepareReschedule(); + system.PrepareReschedule(current_thread->GetProcessorID()); return RESULT_SUCCESS; } @@ -1644,7 +1634,7 @@ static ResultCode SignalProcessWideKey(Core::System& system, VAddr condition_var // Retrieve a list of all threads that are waiting for this condition variable. std::vector<SharedPtr<Thread>> waiting_threads; - const auto& scheduler = Core::System::GetInstance().GlobalScheduler(); + const auto& scheduler = system.GlobalScheduler(); const auto& thread_list = scheduler.GetThreadList(); for (const auto& thread : thread_list) { @@ -1706,8 +1696,7 @@ static ResultCode SignalProcessWideKey(Core::System& system, VAddr condition_var thread->SetLockOwner(nullptr); thread->SetMutexWaitAddress(0); thread->SetWaitHandle(0); - if (thread->GetProcessorID() >= 0) - Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); + system.PrepareReschedule(thread->GetProcessorID()); } else { // Atomically signal that the mutex now has a waiting thread. do { @@ -1731,8 +1720,7 @@ static ResultCode SignalProcessWideKey(Core::System& system, VAddr condition_var thread->SetStatus(ThreadStatus::WaitMutex); owner->AddMutexWaiter(thread); - if (thread->GetProcessorID() >= 0) - Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); + system.PrepareReschedule(thread->GetProcessorID()); } } @@ -1758,13 +1746,10 @@ static ResultCode WaitForAddress(Core::System& system, VAddr address, u32 type, } const auto arbitration_type = static_cast<AddressArbiter::ArbitrationType>(type); - auto& address_arbiter = - system.Kernel().CurrentProcess()->GetAddressArbiter(); + auto& address_arbiter = system.Kernel().CurrentProcess()->GetAddressArbiter(); ResultCode result = address_arbiter.WaitForAddress(address, arbitration_type, value, timeout); if (result == RESULT_SUCCESS) - Core::System::GetInstance() - .CpuCore(GetCurrentThread()->GetProcessorID()) - .PrepareReschedule(); + system.PrepareReschedule(); return result; } @@ -2051,10 +2036,10 @@ static ResultCode SetThreadCoreMask(Core::System& system, Handle thread_handle, return ERR_INVALID_HANDLE; } - Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); + system.PrepareReschedule(thread->GetProcessorID()); thread->ChangeCore(core, affinity_mask); - if (thread->GetProcessorID() >= 0) - Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); + system.PrepareReschedule(thread->GetProcessorID()); + return RESULT_SUCCESS; } @@ -2165,7 +2150,7 @@ static ResultCode SignalEvent(Core::System& system, Handle handle) { } writable_event->Signal(); - Core::System::GetInstance().PrepareReschedule(); + system.PrepareReschedule(); return RESULT_SUCCESS; } diff --git a/src/core/hle/kernel/wait_object.cpp b/src/core/hle/kernel/wait_object.cpp index e035a67e9..a65ec7dbc 100644 --- a/src/core/hle/kernel/wait_object.cpp +++ b/src/core/hle/kernel/wait_object.cpp @@ -97,8 +97,7 @@ void WaitObject::WakeupWaitingThread(SharedPtr<Thread> thread) { } if (resume) { thread->ResumeFromWait(); - if (thread->GetProcessorID() >= 0) - Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule(); + Core::System::GetInstance().PrepareReschedule(thread->GetProcessorID()); } } |