diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2020-01-25 23:55:32 +0100 |
---|---|---|
committer | Fernando Sahmkow <fsahmkow27@gmail.com> | 2020-01-25 23:55:32 +0100 |
commit | 4d6a86b03fe6ae0d98838a21613b66d5196150af (patch) | |
tree | 21f4b8e63e6435b2d816936af8b494882a3cdfb2 /src/core/cpu_core_manager.cpp | |
parent | Kernel: Implement Physical Core. (diff) | |
download | yuzu-4d6a86b03fe6ae0d98838a21613b66d5196150af.tar yuzu-4d6a86b03fe6ae0d98838a21613b66d5196150af.tar.gz yuzu-4d6a86b03fe6ae0d98838a21613b66d5196150af.tar.bz2 yuzu-4d6a86b03fe6ae0d98838a21613b66d5196150af.tar.lz yuzu-4d6a86b03fe6ae0d98838a21613b66d5196150af.tar.xz yuzu-4d6a86b03fe6ae0d98838a21613b66d5196150af.tar.zst yuzu-4d6a86b03fe6ae0d98838a21613b66d5196150af.zip |
Diffstat (limited to 'src/core/cpu_core_manager.cpp')
-rw-r--r-- | src/core/cpu_core_manager.cpp | 63 |
1 files changed, 1 insertions, 62 deletions
diff --git a/src/core/cpu_core_manager.cpp b/src/core/cpu_core_manager.cpp index f04a34133..ab03e8fdf 100644 --- a/src/core/cpu_core_manager.cpp +++ b/src/core/cpu_core_manager.cpp @@ -24,46 +24,16 @@ CpuCoreManager::CpuCoreManager(System& system) : system{system} {} CpuCoreManager::~CpuCoreManager() = default; void CpuCoreManager::Initialize() { - barrier = std::make_unique<CpuBarrier>(); - exclusive_monitor = Cpu::MakeExclusiveMonitor(system.Memory(), cores.size()); for (std::size_t index = 0; index < cores.size(); ++index) { - cores[index] = std::make_unique<Cpu>(system, *exclusive_monitor, *barrier, index); - } -} - -void CpuCoreManager::StartThreads() { - // Create threads for CPU cores 1-3, and build thread_to_cpu map - // CPU core 0 is run on the main thread - thread_to_cpu[std::this_thread::get_id()] = cores[0].get(); - if (!Settings::values.use_multi_core) { - return; - } - - for (std::size_t index = 0; index < core_threads.size(); ++index) { - core_threads[index] = std::make_unique<std::thread>(RunCpuCore, std::cref(system), - std::ref(*cores[index + 1])); - thread_to_cpu[core_threads[index]->get_id()] = cores[index + 1].get(); + cores[index] = std::make_unique<Cpu>(system, index); } } void CpuCoreManager::Shutdown() { - barrier->NotifyEnd(); - if (Settings::values.use_multi_core) { - for (auto& thread : core_threads) { - thread->join(); - thread.reset(); - } - } - - thread_to_cpu.clear(); for (auto& cpu_core : cores) { - cpu_core->Shutdown(); cpu_core.reset(); } - - exclusive_monitor.reset(); - barrier.reset(); } Cpu& CpuCoreManager::GetCore(std::size_t index) { @@ -74,42 +44,17 @@ const Cpu& CpuCoreManager::GetCore(std::size_t index) const { return *cores.at(index); } -ExclusiveMonitor& CpuCoreManager::GetExclusiveMonitor() { - return *exclusive_monitor; -} - -const ExclusiveMonitor& CpuCoreManager::GetExclusiveMonitor() const { - return *exclusive_monitor; -} - Cpu& CpuCoreManager::GetCurrentCore() { - if (Settings::values.use_multi_core) { - const auto& search = thread_to_cpu.find(std::this_thread::get_id()); - ASSERT(search != thread_to_cpu.end()); - ASSERT(search->second); - return *search->second; - } - // Otherwise, use single-threaded mode active_core variable return *cores[active_core]; } const Cpu& CpuCoreManager::GetCurrentCore() const { - if (Settings::values.use_multi_core) { - const auto& search = thread_to_cpu.find(std::this_thread::get_id()); - ASSERT(search != thread_to_cpu.end()); - ASSERT(search->second); - return *search->second; - } - // Otherwise, use single-threaded mode active_core variable return *cores[active_core]; } void CpuCoreManager::RunLoop(bool tight_loop) { - // Update thread_to_cpu in case Core 0 is run from a different host thread - thread_to_cpu[std::this_thread::get_id()] = cores[0].get(); - if (GDBStub::IsServerEnabled()) { GDBStub::HandlePacket(); @@ -143,10 +88,4 @@ void CpuCoreManager::RunLoop(bool tight_loop) { } } -void CpuCoreManager::InvalidateAllInstructionCaches() { - for (auto& cpu : cores) { - cpu->ArmInterface().ClearInstructionCache(); - } -} - } // namespace Core |