From 3f17fe71334a27a60bf54adc55eabe2356ed31f5 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 6 Sep 2018 20:34:51 -0400 Subject: core: Migrate current_process pointer to the kernel Given we now have the kernel as a class, it doesn't make sense to keep the current process pointer within the System class, as processes are related to the kernel. This also gets rid of a subtle case where memory wouldn't be freed on core shutdown, as the current_process pointer would never be reset, causing the pointed to contents to continue to live. --- src/core/core.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/core/core.cpp') diff --git a/src/core/core.cpp b/src/core/core.cpp index bf39ad689..713ee17c1 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -136,7 +136,7 @@ struct System::Impl { if (virtual_filesystem == nullptr) virtual_filesystem = std::make_shared(); - current_process = Kernel::Process::Create(kernel, "main"); + kernel.MakeCurrentProcess(Kernel::Process::Create(kernel, "main")); cpu_barrier = std::make_shared(); cpu_exclusive_monitor = Cpu::MakeExclusiveMonitor(cpu_cores.size()); @@ -202,7 +202,7 @@ struct System::Impl { return init_result; } - const Loader::ResultStatus load_result{app_loader->Load(current_process)}; + const Loader::ResultStatus load_result{app_loader->Load(kernel.CurrentProcess())}; if (load_result != Loader::ResultStatus::Success) { LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", static_cast(load_result)); Shutdown(); @@ -281,7 +281,6 @@ struct System::Impl { std::unique_ptr renderer; std::unique_ptr gpu_core; std::shared_ptr debug_context; - Kernel::SharedPtr current_process; std::shared_ptr cpu_exclusive_monitor; std::shared_ptr cpu_barrier; std::array, NUM_CPU_CORES> cpu_cores; @@ -363,7 +362,11 @@ const std::shared_ptr& System::Scheduler(size_t core_index) { } Kernel::SharedPtr& System::CurrentProcess() { - return impl->current_process; + return impl->kernel.CurrentProcess(); +} + +const Kernel::SharedPtr& System::CurrentProcess() const { + return impl->kernel.CurrentProcess(); } ARM_Interface& System::ArmInterface(size_t core_index) { -- cgit v1.2.3