From c34efbbd60a41afbbab2ff17bbff999519cfb4b6 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 15 Oct 2018 08:42:06 -0400 Subject: core: Make CPUBarrier a unique_ptr instead of a shared_ptr This will always outlive the Cpu instances, since it's destroyed after we destroy the Cpu instances on shutdown, so there's no need for shared ownership semantics here. --- src/core/core_cpu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/core/core_cpu.h') diff --git a/src/core/core_cpu.h b/src/core/core_cpu.h index ee7e04abc..68d83ac8f 100644 --- a/src/core/core_cpu.h +++ b/src/core/core_cpu.h @@ -41,8 +41,8 @@ private: class Cpu { public: - Cpu(std::shared_ptr exclusive_monitor, - std::shared_ptr cpu_barrier, std::size_t core_index); + Cpu(std::shared_ptr exclusive_monitor, CpuBarrier& cpu_barrier, + std::size_t core_index); ~Cpu(); void RunLoop(bool tight_loop = true); @@ -77,7 +77,7 @@ private: void Reschedule(); std::unique_ptr arm_interface; - std::shared_ptr cpu_barrier; + CpuBarrier& cpu_barrier; std::shared_ptr scheduler; std::atomic reschedule_pending = false; -- cgit v1.2.3 From aeadbfa790b11ba859605df8a9357b960084b2a0 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 15 Oct 2018 08:53:01 -0400 Subject: core: Make the exclusive monitor a unique_ptr instead of a shared_ptr Like the barrier, this is owned entirely by the System and will always outlive the encompassing state, so shared ownership semantics aren't necessary here. --- src/core/core_cpu.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/core/core_cpu.h') diff --git a/src/core/core_cpu.h b/src/core/core_cpu.h index 68d83ac8f..3d62de7cb 100644 --- a/src/core/core_cpu.h +++ b/src/core/core_cpu.h @@ -41,8 +41,7 @@ private: class Cpu { public: - Cpu(std::shared_ptr exclusive_monitor, CpuBarrier& cpu_barrier, - std::size_t core_index); + Cpu(ExclusiveMonitor& exclusive_monitor, CpuBarrier& cpu_barrier, std::size_t core_index); ~Cpu(); void RunLoop(bool tight_loop = true); @@ -71,7 +70,7 @@ public: return core_index; } - static std::shared_ptr MakeExclusiveMonitor(std::size_t num_cores); + static std::unique_ptr MakeExclusiveMonitor(std::size_t num_cores); private: void Reschedule(); -- cgit v1.2.3 From 5484742fdaf036db03ac7b8c746df5004f74efad Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 15 Oct 2018 09:25:11 -0400 Subject: core_cpu: Make Cpu scheduler instances unique_ptrs instead of shared_ptrs --- src/core/core_cpu.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/core/core_cpu.h') diff --git a/src/core/core_cpu.h b/src/core/core_cpu.h index 3d62de7cb..1d2bdc6cd 100644 --- a/src/core/core_cpu.h +++ b/src/core/core_cpu.h @@ -58,8 +58,12 @@ public: return *arm_interface; } - const std::shared_ptr& Scheduler() const { - return scheduler; + Kernel::Scheduler& Scheduler() { + return *scheduler; + } + + const Kernel::Scheduler& Scheduler() const { + return *scheduler; } bool IsMainCore() const { @@ -77,7 +81,7 @@ private: std::unique_ptr arm_interface; CpuBarrier& cpu_barrier; - std::shared_ptr scheduler; + std::unique_ptr scheduler; std::atomic reschedule_pending = false; std::size_t core_index; -- cgit v1.2.3