diff options
| author | 2018-10-16 11:21:42 -0400 | |
|---|---|---|
| committer | 2018-10-16 11:21:42 -0400 | |
| commit | 88b8383da28f05b2a30ba853b0578fe625f7dba6 (patch) | |
| tree | f9224c0af9d0ddcc1e2496b638a6108077fcd198 /src | |
| parent | Merge pull request #1508 from lioncash/unique-reg (diff) | |
| parent | core_cpu: Make Cpu scheduler instances unique_ptrs instead of shared_ptrs (diff) | |
| download | yuzu-88b8383da28f05b2a30ba853b0578fe625f7dba6.tar.gz yuzu-88b8383da28f05b2a30ba853b0578fe625f7dba6.tar.xz yuzu-88b8383da28f05b2a30ba853b0578fe625f7dba6.zip | |
Merge pull request #1502 from lioncash/unique
core: Convert shared_ptr instances into unique_ptr instances where applicable for System and Cpu
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic.cpp | 7 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic.h | 4 | ||||
| -rw-r--r-- | src/core/core.cpp | 41 | ||||
| -rw-r--r-- | src/core/core.h | 8 | ||||
| -rw-r--r-- | src/core/core_cpu.cpp | 14 | ||||
| -rw-r--r-- | src/core/core_cpu.h | 17 | ||||
| -rw-r--r-- | src/core/gdbstub/gdbstub.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/kernel/address_arbiter.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 10 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 16 | ||||
| -rw-r--r-- | src/yuzu/debugger/wait_tree.cpp | 9 |
12 files changed, 76 insertions, 60 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index 0762321a9..4d2491870 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp | |||
| @@ -144,7 +144,7 @@ std::unique_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit() const { | |||
| 144 | 144 | ||
| 145 | // Multi-process state | 145 | // Multi-process state |
| 146 | config.processor_id = core_index; | 146 | config.processor_id = core_index; |
| 147 | config.global_monitor = &exclusive_monitor->monitor; | 147 | config.global_monitor = &exclusive_monitor.monitor; |
| 148 | 148 | ||
| 149 | // System registers | 149 | // System registers |
| 150 | config.tpidrro_el0 = &cb->tpidrro_el0; | 150 | config.tpidrro_el0 = &cb->tpidrro_el0; |
| @@ -171,10 +171,9 @@ void ARM_Dynarmic::Step() { | |||
| 171 | cb->InterpreterFallback(jit->GetPC(), 1); | 171 | cb->InterpreterFallback(jit->GetPC(), 1); |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | ARM_Dynarmic::ARM_Dynarmic(std::shared_ptr<ExclusiveMonitor> exclusive_monitor, | 174 | ARM_Dynarmic::ARM_Dynarmic(ExclusiveMonitor& exclusive_monitor, std::size_t core_index) |
| 175 | std::size_t core_index) | ||
| 176 | : cb(std::make_unique<ARM_Dynarmic_Callbacks>(*this)), core_index{core_index}, | 175 | : cb(std::make_unique<ARM_Dynarmic_Callbacks>(*this)), core_index{core_index}, |
| 177 | exclusive_monitor{std::dynamic_pointer_cast<DynarmicExclusiveMonitor>(exclusive_monitor)} { | 176 | exclusive_monitor{dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor)} { |
| 178 | ThreadContext ctx{}; | 177 | ThreadContext ctx{}; |
| 179 | inner_unicorn.SaveContext(ctx); | 178 | inner_unicorn.SaveContext(ctx); |
| 180 | PageTableChanged(); | 179 | PageTableChanged(); |
diff --git a/src/core/arm/dynarmic/arm_dynarmic.h b/src/core/arm/dynarmic/arm_dynarmic.h index 4ee92ee27..512bf8ce9 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.h +++ b/src/core/arm/dynarmic/arm_dynarmic.h | |||
| @@ -23,7 +23,7 @@ class DynarmicExclusiveMonitor; | |||
| 23 | 23 | ||
| 24 | class ARM_Dynarmic final : public ARM_Interface { | 24 | class ARM_Dynarmic final : public ARM_Interface { |
| 25 | public: | 25 | public: |
| 26 | ARM_Dynarmic(std::shared_ptr<ExclusiveMonitor> exclusive_monitor, std::size_t core_index); | 26 | ARM_Dynarmic(ExclusiveMonitor& exclusive_monitor, std::size_t core_index); |
| 27 | ~ARM_Dynarmic(); | 27 | ~ARM_Dynarmic(); |
| 28 | 28 | ||
| 29 | void MapBackingMemory(VAddr address, std::size_t size, u8* memory, | 29 | void MapBackingMemory(VAddr address, std::size_t size, u8* memory, |
| @@ -62,7 +62,7 @@ private: | |||
| 62 | ARM_Unicorn inner_unicorn; | 62 | ARM_Unicorn inner_unicorn; |
| 63 | 63 | ||
| 64 | std::size_t core_index; | 64 | std::size_t core_index; |
| 65 | std::shared_ptr<DynarmicExclusiveMonitor> exclusive_monitor; | 65 | DynarmicExclusiveMonitor& exclusive_monitor; |
| 66 | 66 | ||
| 67 | Memory::PageTable* current_page_table = nullptr; | 67 | Memory::PageTable* current_page_table = nullptr; |
| 68 | }; | 68 | }; |
diff --git a/src/core/core.cpp b/src/core/core.cpp index 32baa40dc..3c57a62ec 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -71,9 +71,9 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, | |||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | /// Runs a CPU core while the system is powered on | 73 | /// Runs a CPU core while the system is powered on |
| 74 | void RunCpuCore(std::shared_ptr<Cpu> cpu_state) { | 74 | void RunCpuCore(Cpu& cpu_state) { |
| 75 | while (Core::System::GetInstance().IsPoweredOn()) { | 75 | while (Core::System::GetInstance().IsPoweredOn()) { |
| 76 | cpu_state->RunLoop(true); | 76 | cpu_state.RunLoop(true); |
| 77 | } | 77 | } |
| 78 | } | 78 | } |
| 79 | } // Anonymous namespace | 79 | } // Anonymous namespace |
| @@ -95,7 +95,7 @@ struct System::Impl { | |||
| 95 | status = ResultStatus::Success; | 95 | status = ResultStatus::Success; |
| 96 | 96 | ||
| 97 | // Update thread_to_cpu in case Core 0 is run from a different host thread | 97 | // Update thread_to_cpu in case Core 0 is run from a different host thread |
| 98 | thread_to_cpu[std::this_thread::get_id()] = cpu_cores[0]; | 98 | thread_to_cpu[std::this_thread::get_id()] = cpu_cores[0].get(); |
| 99 | 99 | ||
| 100 | if (GDBStub::IsServerEnabled()) { | 100 | if (GDBStub::IsServerEnabled()) { |
| 101 | GDBStub::HandlePacket(); | 101 | GDBStub::HandlePacket(); |
| @@ -139,10 +139,10 @@ struct System::Impl { | |||
| 139 | auto main_process = Kernel::Process::Create(kernel, "main"); | 139 | auto main_process = Kernel::Process::Create(kernel, "main"); |
| 140 | kernel.MakeCurrentProcess(main_process.get()); | 140 | kernel.MakeCurrentProcess(main_process.get()); |
| 141 | 141 | ||
| 142 | cpu_barrier = std::make_shared<CpuBarrier>(); | 142 | cpu_barrier = std::make_unique<CpuBarrier>(); |
| 143 | cpu_exclusive_monitor = Cpu::MakeExclusiveMonitor(cpu_cores.size()); | 143 | cpu_exclusive_monitor = Cpu::MakeExclusiveMonitor(cpu_cores.size()); |
| 144 | for (std::size_t index = 0; index < cpu_cores.size(); ++index) { | 144 | for (std::size_t index = 0; index < cpu_cores.size(); ++index) { |
| 145 | cpu_cores[index] = std::make_shared<Cpu>(cpu_exclusive_monitor, cpu_barrier, index); | 145 | cpu_cores[index] = std::make_unique<Cpu>(*cpu_exclusive_monitor, *cpu_barrier, index); |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | telemetry_session = std::make_unique<Core::TelemetrySession>(); | 148 | telemetry_session = std::make_unique<Core::TelemetrySession>(); |
| @@ -160,12 +160,12 @@ struct System::Impl { | |||
| 160 | 160 | ||
| 161 | // Create threads for CPU cores 1-3, and build thread_to_cpu map | 161 | // Create threads for CPU cores 1-3, and build thread_to_cpu map |
| 162 | // CPU core 0 is run on the main thread | 162 | // CPU core 0 is run on the main thread |
| 163 | thread_to_cpu[std::this_thread::get_id()] = cpu_cores[0]; | 163 | thread_to_cpu[std::this_thread::get_id()] = cpu_cores[0].get(); |
| 164 | if (Settings::values.use_multi_core) { | 164 | if (Settings::values.use_multi_core) { |
| 165 | for (std::size_t index = 0; index < cpu_core_threads.size(); ++index) { | 165 | for (std::size_t index = 0; index < cpu_core_threads.size(); ++index) { |
| 166 | cpu_core_threads[index] = | 166 | cpu_core_threads[index] = |
| 167 | std::make_unique<std::thread>(RunCpuCore, cpu_cores[index + 1]); | 167 | std::make_unique<std::thread>(RunCpuCore, std::ref(*cpu_cores[index + 1])); |
| 168 | thread_to_cpu[cpu_core_threads[index]->get_id()] = cpu_cores[index + 1]; | 168 | thread_to_cpu[cpu_core_threads[index]->get_id()] = cpu_cores[index + 1].get(); |
| 169 | } | 169 | } |
| 170 | } | 170 | } |
| 171 | 171 | ||
| @@ -245,6 +245,7 @@ struct System::Impl { | |||
| 245 | for (auto& cpu_core : cpu_cores) { | 245 | for (auto& cpu_core : cpu_cores) { |
| 246 | cpu_core.reset(); | 246 | cpu_core.reset(); |
| 247 | } | 247 | } |
| 248 | cpu_exclusive_monitor.reset(); | ||
| 248 | cpu_barrier.reset(); | 249 | cpu_barrier.reset(); |
| 249 | 250 | ||
| 250 | // Shutdown kernel and core timing | 251 | // Shutdown kernel and core timing |
| @@ -282,9 +283,9 @@ struct System::Impl { | |||
| 282 | std::unique_ptr<VideoCore::RendererBase> renderer; | 283 | std::unique_ptr<VideoCore::RendererBase> renderer; |
| 283 | std::unique_ptr<Tegra::GPU> gpu_core; | 284 | std::unique_ptr<Tegra::GPU> gpu_core; |
| 284 | std::shared_ptr<Tegra::DebugContext> debug_context; | 285 | std::shared_ptr<Tegra::DebugContext> debug_context; |
| 285 | std::shared_ptr<ExclusiveMonitor> cpu_exclusive_monitor; | 286 | std::unique_ptr<ExclusiveMonitor> cpu_exclusive_monitor; |
| 286 | std::shared_ptr<CpuBarrier> cpu_barrier; | 287 | std::unique_ptr<CpuBarrier> cpu_barrier; |
| 287 | std::array<std::shared_ptr<Cpu>, NUM_CPU_CORES> cpu_cores; | 288 | std::array<std::unique_ptr<Cpu>, NUM_CPU_CORES> cpu_cores; |
| 288 | std::array<std::unique_ptr<std::thread>, NUM_CPU_CORES - 1> cpu_core_threads; | 289 | std::array<std::unique_ptr<std::thread>, NUM_CPU_CORES - 1> cpu_core_threads; |
| 289 | std::size_t active_core{}; ///< Active core, only used in single thread mode | 290 | std::size_t active_core{}; ///< Active core, only used in single thread mode |
| 290 | 291 | ||
| @@ -298,7 +299,7 @@ struct System::Impl { | |||
| 298 | std::string status_details = ""; | 299 | std::string status_details = ""; |
| 299 | 300 | ||
| 300 | /// Map of guest threads to CPU cores | 301 | /// Map of guest threads to CPU cores |
| 301 | std::map<std::thread::id, std::shared_ptr<Cpu>> thread_to_cpu; | 302 | std::map<std::thread::id, Cpu*> thread_to_cpu; |
| 302 | 303 | ||
| 303 | Core::PerfStats perf_stats; | 304 | Core::PerfStats perf_stats; |
| 304 | Core::FrameLimiter frame_limiter; | 305 | Core::FrameLimiter frame_limiter; |
| @@ -354,12 +355,15 @@ std::size_t System::CurrentCoreIndex() { | |||
| 354 | } | 355 | } |
| 355 | 356 | ||
| 356 | Kernel::Scheduler& System::CurrentScheduler() { | 357 | Kernel::Scheduler& System::CurrentScheduler() { |
| 357 | return *CurrentCpuCore().Scheduler(); | 358 | return CurrentCpuCore().Scheduler(); |
| 358 | } | 359 | } |
| 359 | 360 | ||
| 360 | const std::shared_ptr<Kernel::Scheduler>& System::Scheduler(std::size_t core_index) { | 361 | Kernel::Scheduler& System::Scheduler(std::size_t core_index) { |
| 361 | ASSERT(core_index < NUM_CPU_CORES); | 362 | return CpuCore(core_index).Scheduler(); |
| 362 | return impl->cpu_cores[core_index]->Scheduler(); | 363 | } |
| 364 | |||
| 365 | const Kernel::Scheduler& System::Scheduler(std::size_t core_index) const { | ||
| 366 | return CpuCore(core_index).Scheduler(); | ||
| 363 | } | 367 | } |
| 364 | 368 | ||
| 365 | Kernel::Process* System::CurrentProcess() { | 369 | Kernel::Process* System::CurrentProcess() { |
| @@ -380,6 +384,11 @@ Cpu& System::CpuCore(std::size_t core_index) { | |||
| 380 | return *impl->cpu_cores[core_index]; | 384 | return *impl->cpu_cores[core_index]; |
| 381 | } | 385 | } |
| 382 | 386 | ||
| 387 | const Cpu& System::CpuCore(std::size_t core_index) const { | ||
| 388 | ASSERT(core_index < NUM_CPU_CORES); | ||
| 389 | return *impl->cpu_cores[core_index]; | ||
| 390 | } | ||
| 391 | |||
| 383 | ExclusiveMonitor& System::Monitor() { | 392 | ExclusiveMonitor& System::Monitor() { |
| 384 | return *impl->cpu_exclusive_monitor; | 393 | return *impl->cpu_exclusive_monitor; |
| 385 | } | 394 | } |
diff --git a/src/core/core.h b/src/core/core.h index ea4d53914..173be45f8 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -156,6 +156,9 @@ public: | |||
| 156 | /// Gets a CPU interface to the CPU core with the specified index | 156 | /// Gets a CPU interface to the CPU core with the specified index |
| 157 | Cpu& CpuCore(std::size_t core_index); | 157 | Cpu& CpuCore(std::size_t core_index); |
| 158 | 158 | ||
| 159 | /// Gets a CPU interface to the CPU core with the specified index | ||
| 160 | const Cpu& CpuCore(std::size_t core_index) const; | ||
| 161 | |||
| 159 | /// Gets the exclusive monitor | 162 | /// Gets the exclusive monitor |
| 160 | ExclusiveMonitor& Monitor(); | 163 | ExclusiveMonitor& Monitor(); |
| 161 | 164 | ||
| @@ -172,7 +175,10 @@ public: | |||
| 172 | const VideoCore::RendererBase& Renderer() const; | 175 | const VideoCore::RendererBase& Renderer() const; |
| 173 | 176 | ||
| 174 | /// Gets the scheduler for the CPU core with the specified index | 177 | /// Gets the scheduler for the CPU core with the specified index |
| 175 | const std::shared_ptr<Kernel::Scheduler>& Scheduler(std::size_t core_index); | 178 | Kernel::Scheduler& Scheduler(std::size_t core_index); |
| 179 | |||
| 180 | /// Gets the scheduler for the CPU core with the specified index | ||
| 181 | const Kernel::Scheduler& Scheduler(std::size_t core_index) const; | ||
| 176 | 182 | ||
| 177 | /// Provides a pointer to the current process | 183 | /// Provides a pointer to the current process |
| 178 | Kernel::Process* CurrentProcess(); | 184 | Kernel::Process* CurrentProcess(); |
diff --git a/src/core/core_cpu.cpp b/src/core/core_cpu.cpp index 265f8ed9c..fffda8a99 100644 --- a/src/core/core_cpu.cpp +++ b/src/core/core_cpu.cpp | |||
| @@ -49,10 +49,8 @@ bool CpuBarrier::Rendezvous() { | |||
| 49 | return false; | 49 | return false; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | Cpu::Cpu(std::shared_ptr<ExclusiveMonitor> exclusive_monitor, | 52 | Cpu::Cpu(ExclusiveMonitor& exclusive_monitor, CpuBarrier& cpu_barrier, std::size_t core_index) |
| 53 | std::shared_ptr<CpuBarrier> cpu_barrier, std::size_t core_index) | 53 | : cpu_barrier{cpu_barrier}, core_index{core_index} { |
| 54 | : cpu_barrier{std::move(cpu_barrier)}, core_index{core_index} { | ||
| 55 | |||
| 56 | if (Settings::values.use_cpu_jit) { | 54 | if (Settings::values.use_cpu_jit) { |
| 57 | #ifdef ARCHITECTURE_x86_64 | 55 | #ifdef ARCHITECTURE_x86_64 |
| 58 | arm_interface = std::make_unique<ARM_Dynarmic>(exclusive_monitor, core_index); | 56 | arm_interface = std::make_unique<ARM_Dynarmic>(exclusive_monitor, core_index); |
| @@ -64,15 +62,15 @@ Cpu::Cpu(std::shared_ptr<ExclusiveMonitor> exclusive_monitor, | |||
| 64 | arm_interface = std::make_unique<ARM_Unicorn>(); | 62 | arm_interface = std::make_unique<ARM_Unicorn>(); |
| 65 | } | 63 | } |
| 66 | 64 | ||
| 67 | scheduler = std::make_shared<Kernel::Scheduler>(*arm_interface); | 65 | scheduler = std::make_unique<Kernel::Scheduler>(*arm_interface); |
| 68 | } | 66 | } |
| 69 | 67 | ||
| 70 | Cpu::~Cpu() = default; | 68 | Cpu::~Cpu() = default; |
| 71 | 69 | ||
| 72 | std::shared_ptr<ExclusiveMonitor> Cpu::MakeExclusiveMonitor(std::size_t num_cores) { | 70 | std::unique_ptr<ExclusiveMonitor> Cpu::MakeExclusiveMonitor(std::size_t num_cores) { |
| 73 | if (Settings::values.use_cpu_jit) { | 71 | if (Settings::values.use_cpu_jit) { |
| 74 | #ifdef ARCHITECTURE_x86_64 | 72 | #ifdef ARCHITECTURE_x86_64 |
| 75 | return std::make_shared<DynarmicExclusiveMonitor>(num_cores); | 73 | return std::make_unique<DynarmicExclusiveMonitor>(num_cores); |
| 76 | #else | 74 | #else |
| 77 | return nullptr; // TODO(merry): Passthrough exclusive monitor | 75 | return nullptr; // TODO(merry): Passthrough exclusive monitor |
| 78 | #endif | 76 | #endif |
| @@ -83,7 +81,7 @@ std::shared_ptr<ExclusiveMonitor> Cpu::MakeExclusiveMonitor(std::size_t num_core | |||
| 83 | 81 | ||
| 84 | void Cpu::RunLoop(bool tight_loop) { | 82 | void Cpu::RunLoop(bool tight_loop) { |
| 85 | // Wait for all other CPU cores to complete the previous slice, such that they run in lock-step | 83 | // Wait for all other CPU cores to complete the previous slice, such that they run in lock-step |
| 86 | if (!cpu_barrier->Rendezvous()) { | 84 | if (!cpu_barrier.Rendezvous()) { |
| 87 | // If rendezvous failed, session has been killed | 85 | // If rendezvous failed, session has been killed |
| 88 | return; | 86 | return; |
| 89 | } | 87 | } |
diff --git a/src/core/core_cpu.h b/src/core/core_cpu.h index ee7e04abc..1d2bdc6cd 100644 --- a/src/core/core_cpu.h +++ b/src/core/core_cpu.h | |||
| @@ -41,8 +41,7 @@ private: | |||
| 41 | 41 | ||
| 42 | class Cpu { | 42 | class Cpu { |
| 43 | public: | 43 | public: |
| 44 | Cpu(std::shared_ptr<ExclusiveMonitor> exclusive_monitor, | 44 | Cpu(ExclusiveMonitor& exclusive_monitor, CpuBarrier& cpu_barrier, std::size_t core_index); |
| 45 | std::shared_ptr<CpuBarrier> cpu_barrier, std::size_t core_index); | ||
| 46 | ~Cpu(); | 45 | ~Cpu(); |
| 47 | 46 | ||
| 48 | void RunLoop(bool tight_loop = true); | 47 | void RunLoop(bool tight_loop = true); |
| @@ -59,8 +58,12 @@ public: | |||
| 59 | return *arm_interface; | 58 | return *arm_interface; |
| 60 | } | 59 | } |
| 61 | 60 | ||
| 62 | const std::shared_ptr<Kernel::Scheduler>& Scheduler() const { | 61 | Kernel::Scheduler& Scheduler() { |
| 63 | return scheduler; | 62 | return *scheduler; |
| 63 | } | ||
| 64 | |||
| 65 | const Kernel::Scheduler& Scheduler() const { | ||
| 66 | return *scheduler; | ||
| 64 | } | 67 | } |
| 65 | 68 | ||
| 66 | bool IsMainCore() const { | 69 | bool IsMainCore() const { |
| @@ -71,14 +74,14 @@ public: | |||
| 71 | return core_index; | 74 | return core_index; |
| 72 | } | 75 | } |
| 73 | 76 | ||
| 74 | static std::shared_ptr<ExclusiveMonitor> MakeExclusiveMonitor(std::size_t num_cores); | 77 | static std::unique_ptr<ExclusiveMonitor> MakeExclusiveMonitor(std::size_t num_cores); |
| 75 | 78 | ||
| 76 | private: | 79 | private: |
| 77 | void Reschedule(); | 80 | void Reschedule(); |
| 78 | 81 | ||
| 79 | std::unique_ptr<ARM_Interface> arm_interface; | 82 | std::unique_ptr<ARM_Interface> arm_interface; |
| 80 | std::shared_ptr<CpuBarrier> cpu_barrier; | 83 | CpuBarrier& cpu_barrier; |
| 81 | std::shared_ptr<Kernel::Scheduler> scheduler; | 84 | std::unique_ptr<Kernel::Scheduler> scheduler; |
| 82 | 85 | ||
| 83 | std::atomic<bool> reschedule_pending = false; | 86 | std::atomic<bool> reschedule_pending = false; |
| 84 | std::size_t core_index; | 87 | std::size_t core_index; |
diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index e961ef121..bdcc889e0 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp | |||
| @@ -207,7 +207,7 @@ void RegisterModule(std::string name, VAddr beg, VAddr end, bool add_elf_ext) { | |||
| 207 | 207 | ||
| 208 | static Kernel::Thread* FindThreadById(int id) { | 208 | static Kernel::Thread* FindThreadById(int id) { |
| 209 | for (u32 core = 0; core < Core::NUM_CPU_CORES; core++) { | 209 | for (u32 core = 0; core < Core::NUM_CPU_CORES; core++) { |
| 210 | const auto& threads = Core::System::GetInstance().Scheduler(core)->GetThreadList(); | 210 | const auto& threads = Core::System::GetInstance().Scheduler(core).GetThreadList(); |
| 211 | for (auto& thread : threads) { | 211 | for (auto& thread : threads) { |
| 212 | if (thread->GetThreadID() == static_cast<u32>(id)) { | 212 | if (thread->GetThreadID() == static_cast<u32>(id)) { |
| 213 | current_core = core; | 213 | current_core = core; |
| @@ -597,7 +597,7 @@ static void HandleQuery() { | |||
| 597 | } else if (strncmp(query, "fThreadInfo", strlen("fThreadInfo")) == 0) { | 597 | } else if (strncmp(query, "fThreadInfo", strlen("fThreadInfo")) == 0) { |
| 598 | std::string val = "m"; | 598 | std::string val = "m"; |
| 599 | for (u32 core = 0; core < Core::NUM_CPU_CORES; core++) { | 599 | for (u32 core = 0; core < Core::NUM_CPU_CORES; core++) { |
| 600 | const auto& threads = Core::System::GetInstance().Scheduler(core)->GetThreadList(); | 600 | const auto& threads = Core::System::GetInstance().Scheduler(core).GetThreadList(); |
| 601 | for (const auto& thread : threads) { | 601 | for (const auto& thread : threads) { |
| 602 | val += fmt::format("{:x}", thread->GetThreadID()); | 602 | val += fmt::format("{:x}", thread->GetThreadID()); |
| 603 | val += ","; | 603 | val += ","; |
| @@ -612,7 +612,7 @@ static void HandleQuery() { | |||
| 612 | buffer += "l<?xml version=\"1.0\"?>"; | 612 | buffer += "l<?xml version=\"1.0\"?>"; |
| 613 | buffer += "<threads>"; | 613 | buffer += "<threads>"; |
| 614 | for (u32 core = 0; core < Core::NUM_CPU_CORES; core++) { | 614 | for (u32 core = 0; core < Core::NUM_CPU_CORES; core++) { |
| 615 | const auto& threads = Core::System::GetInstance().Scheduler(core)->GetThreadList(); | 615 | const auto& threads = Core::System::GetInstance().Scheduler(core).GetThreadList(); |
| 616 | for (const auto& thread : threads) { | 616 | for (const auto& thread : threads) { |
| 617 | buffer += | 617 | buffer += |
| 618 | fmt::format(R"*(<thread id="{:x}" core="{:d}" name="Thread {:x}"></thread>)*", | 618 | fmt::format(R"*(<thread id="{:x}" core="{:d}" name="Thread {:x}"></thread>)*", |
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp index ebf193930..57157beb4 100644 --- a/src/core/hle/kernel/address_arbiter.cpp +++ b/src/core/hle/kernel/address_arbiter.cpp | |||
| @@ -39,7 +39,7 @@ static std::vector<SharedPtr<Thread>> GetThreadsWaitingOnAddress(VAddr address) | |||
| 39 | std::vector<SharedPtr<Thread>>& waiting_threads, | 39 | std::vector<SharedPtr<Thread>>& waiting_threads, |
| 40 | VAddr arb_addr) { | 40 | VAddr arb_addr) { |
| 41 | const auto& scheduler = Core::System::GetInstance().Scheduler(core_index); | 41 | const auto& scheduler = Core::System::GetInstance().Scheduler(core_index); |
| 42 | const auto& thread_list = scheduler->GetThreadList(); | 42 | const auto& thread_list = scheduler.GetThreadList(); |
| 43 | 43 | ||
| 44 | for (const auto& thread : thread_list) { | 44 | for (const auto& thread : thread_list) { |
| 45 | if (thread->GetArbiterWaitAddress() == arb_addr) | 45 | if (thread->GetArbiterWaitAddress() == arb_addr) |
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index c80b2c507..073dd5a7d 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -153,11 +153,11 @@ void Process::PrepareForTermination() { | |||
| 153 | } | 153 | } |
| 154 | }; | 154 | }; |
| 155 | 155 | ||
| 156 | auto& system = Core::System::GetInstance(); | 156 | const auto& system = Core::System::GetInstance(); |
| 157 | stop_threads(system.Scheduler(0)->GetThreadList()); | 157 | stop_threads(system.Scheduler(0).GetThreadList()); |
| 158 | stop_threads(system.Scheduler(1)->GetThreadList()); | 158 | stop_threads(system.Scheduler(1).GetThreadList()); |
| 159 | stop_threads(system.Scheduler(2)->GetThreadList()); | 159 | stop_threads(system.Scheduler(2).GetThreadList()); |
| 160 | stop_threads(system.Scheduler(3)->GetThreadList()); | 160 | stop_threads(system.Scheduler(3).GetThreadList()); |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | /** | 163 | /** |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 7a053da1e..3e5f11f2b 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -809,7 +809,7 @@ static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target | |||
| 809 | std::vector<SharedPtr<Thread>>& waiting_threads, | 809 | std::vector<SharedPtr<Thread>>& waiting_threads, |
| 810 | VAddr condvar_addr) { | 810 | VAddr condvar_addr) { |
| 811 | const auto& scheduler = Core::System::GetInstance().Scheduler(core_index); | 811 | const auto& scheduler = Core::System::GetInstance().Scheduler(core_index); |
| 812 | const auto& thread_list = scheduler->GetThreadList(); | 812 | const auto& thread_list = scheduler.GetThreadList(); |
| 813 | 813 | ||
| 814 | for (const auto& thread : thread_list) { | 814 | for (const auto& thread : thread_list) { |
| 815 | if (thread->GetCondVarWaitAddress() == condvar_addr) | 815 | if (thread->GetCondVarWaitAddress() == condvar_addr) |
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 352ce1725..35ec98c1a 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -97,7 +97,7 @@ void Thread::CancelWakeupTimer() { | |||
| 97 | static boost::optional<s32> GetNextProcessorId(u64 mask) { | 97 | static boost::optional<s32> GetNextProcessorId(u64 mask) { |
| 98 | for (s32 index = 0; index < Core::NUM_CPU_CORES; ++index) { | 98 | for (s32 index = 0; index < Core::NUM_CPU_CORES; ++index) { |
| 99 | if (mask & (1ULL << index)) { | 99 | if (mask & (1ULL << index)) { |
| 100 | if (!Core::System::GetInstance().Scheduler(index)->GetCurrentThread()) { | 100 | if (!Core::System::GetInstance().Scheduler(index).GetCurrentThread()) { |
| 101 | // Core is enabled and not running any threads, use this one | 101 | // Core is enabled and not running any threads, use this one |
| 102 | return index; | 102 | return index; |
| 103 | } | 103 | } |
| @@ -147,14 +147,14 @@ void Thread::ResumeFromWait() { | |||
| 147 | new_processor_id = processor_id; | 147 | new_processor_id = processor_id; |
| 148 | } | 148 | } |
| 149 | if (ideal_core != -1 && | 149 | if (ideal_core != -1 && |
| 150 | Core::System::GetInstance().Scheduler(ideal_core)->GetCurrentThread() == nullptr) { | 150 | Core::System::GetInstance().Scheduler(ideal_core).GetCurrentThread() == nullptr) { |
| 151 | new_processor_id = ideal_core; | 151 | new_processor_id = ideal_core; |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | ASSERT(*new_processor_id < 4); | 154 | ASSERT(*new_processor_id < 4); |
| 155 | 155 | ||
| 156 | // Add thread to new core's scheduler | 156 | // Add thread to new core's scheduler |
| 157 | auto& next_scheduler = Core::System::GetInstance().Scheduler(*new_processor_id); | 157 | auto* next_scheduler = &Core::System::GetInstance().Scheduler(*new_processor_id); |
| 158 | 158 | ||
| 159 | if (*new_processor_id != processor_id) { | 159 | if (*new_processor_id != processor_id) { |
| 160 | // Remove thread from previous core's scheduler | 160 | // Remove thread from previous core's scheduler |
| @@ -169,7 +169,7 @@ void Thread::ResumeFromWait() { | |||
| 169 | next_scheduler->ScheduleThread(this, current_priority); | 169 | next_scheduler->ScheduleThread(this, current_priority); |
| 170 | 170 | ||
| 171 | // Change thread's scheduler | 171 | // Change thread's scheduler |
| 172 | scheduler = next_scheduler.get(); | 172 | scheduler = next_scheduler; |
| 173 | 173 | ||
| 174 | Core::System::GetInstance().CpuCore(processor_id).PrepareReschedule(); | 174 | Core::System::GetInstance().CpuCore(processor_id).PrepareReschedule(); |
| 175 | } | 175 | } |
| @@ -230,7 +230,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(KernelCore& kernel, std::string name | |||
| 230 | thread->name = std::move(name); | 230 | thread->name = std::move(name); |
| 231 | thread->callback_handle = kernel.ThreadWakeupCallbackHandleTable().Create(thread).Unwrap(); | 231 | thread->callback_handle = kernel.ThreadWakeupCallbackHandleTable().Create(thread).Unwrap(); |
| 232 | thread->owner_process = &owner_process; | 232 | thread->owner_process = &owner_process; |
| 233 | thread->scheduler = Core::System::GetInstance().Scheduler(processor_id).get(); | 233 | thread->scheduler = &Core::System::GetInstance().Scheduler(processor_id); |
| 234 | thread->scheduler->AddThread(thread, priority); | 234 | thread->scheduler->AddThread(thread, priority); |
| 235 | thread->tls_address = thread->owner_process->MarkNextAvailableTLSSlotAsUsed(*thread); | 235 | thread->tls_address = thread->owner_process->MarkNextAvailableTLSSlotAsUsed(*thread); |
| 236 | 236 | ||
| @@ -375,14 +375,14 @@ void Thread::ChangeCore(u32 core, u64 mask) { | |||
| 375 | new_processor_id = processor_id; | 375 | new_processor_id = processor_id; |
| 376 | } | 376 | } |
| 377 | if (ideal_core != -1 && | 377 | if (ideal_core != -1 && |
| 378 | Core::System::GetInstance().Scheduler(ideal_core)->GetCurrentThread() == nullptr) { | 378 | Core::System::GetInstance().Scheduler(ideal_core).GetCurrentThread() == nullptr) { |
| 379 | new_processor_id = ideal_core; | 379 | new_processor_id = ideal_core; |
| 380 | } | 380 | } |
| 381 | 381 | ||
| 382 | ASSERT(*new_processor_id < 4); | 382 | ASSERT(*new_processor_id < 4); |
| 383 | 383 | ||
| 384 | // Add thread to new core's scheduler | 384 | // Add thread to new core's scheduler |
| 385 | auto& next_scheduler = Core::System::GetInstance().Scheduler(*new_processor_id); | 385 | auto* next_scheduler = &Core::System::GetInstance().Scheduler(*new_processor_id); |
| 386 | 386 | ||
| 387 | if (*new_processor_id != processor_id) { | 387 | if (*new_processor_id != processor_id) { |
| 388 | // Remove thread from previous core's scheduler | 388 | // Remove thread from previous core's scheduler |
| @@ -397,7 +397,7 @@ void Thread::ChangeCore(u32 core, u64 mask) { | |||
| 397 | next_scheduler->ScheduleThread(this, current_priority); | 397 | next_scheduler->ScheduleThread(this, current_priority); |
| 398 | 398 | ||
| 399 | // Change thread's scheduler | 399 | // Change thread's scheduler |
| 400 | scheduler = next_scheduler.get(); | 400 | scheduler = next_scheduler; |
| 401 | 401 | ||
| 402 | Core::System::GetInstance().CpuCore(processor_id).PrepareReschedule(); | 402 | Core::System::GetInstance().CpuCore(processor_id).PrepareReschedule(); |
| 403 | } | 403 | } |
diff --git a/src/yuzu/debugger/wait_tree.cpp b/src/yuzu/debugger/wait_tree.cpp index 4a09da685..7403e9ccd 100644 --- a/src/yuzu/debugger/wait_tree.cpp +++ b/src/yuzu/debugger/wait_tree.cpp | |||
| @@ -66,10 +66,11 @@ std::vector<std::unique_ptr<WaitTreeThread>> WaitTreeItem::MakeThreadItemList() | |||
| 66 | } | 66 | } |
| 67 | }; | 67 | }; |
| 68 | 68 | ||
| 69 | add_threads(Core::System::GetInstance().Scheduler(0)->GetThreadList()); | 69 | const auto& system = Core::System::GetInstance(); |
| 70 | add_threads(Core::System::GetInstance().Scheduler(1)->GetThreadList()); | 70 | add_threads(system.Scheduler(0).GetThreadList()); |
| 71 | add_threads(Core::System::GetInstance().Scheduler(2)->GetThreadList()); | 71 | add_threads(system.Scheduler(1).GetThreadList()); |
| 72 | add_threads(Core::System::GetInstance().Scheduler(3)->GetThreadList()); | 72 | add_threads(system.Scheduler(2).GetThreadList()); |
| 73 | add_threads(system.Scheduler(3).GetThreadList()); | ||
| 73 | 74 | ||
| 74 | return item_list; | 75 | return item_list; |
| 75 | } | 76 | } |