From 57a71f899a95ccaa2984c1cb35c083221a29fd6e Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Fri, 29 Mar 2019 17:02:57 -0400 Subject: [PATCH] Add interfacing to the Global Scheduler --- src/core/core.cpp | 10 ++++++++++ src/core/core.h | 7 +++++++ src/core/hle/kernel/kernel.cpp | 10 ++++++++++ src/core/hle/kernel/kernel.h | 7 +++++++ 4 files changed, 34 insertions(+) diff --git a/src/core/core.cpp b/src/core/core.cpp index 4d0ac72a5..5565840fd 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -444,6 +444,16 @@ const Kernel::Scheduler& System::Scheduler(std::size_t core_index) const { return CpuCore(core_index).Scheduler(); } +/// Gets the global scheduler +Kernel::GlobalScheduler& System::GlobalScheduler() { + return impl->kernel.GlobalScheduler(); +} + +/// Gets the global scheduler +const Kernel::GlobalScheduler& System::GlobalScheduler() const { + return impl->kernel.GlobalScheduler(); +} + Kernel::Process* System::CurrentProcess() { return impl->kernel.CurrentProcess(); } diff --git a/src/core/core.h b/src/core/core.h index 90e7ac607..2a002f6d7 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -27,6 +27,7 @@ namespace Kernel { class KernelCore; class Process; class Scheduler; +class GlobalScheduler; } // namespace Kernel namespace Loader { @@ -238,6 +239,12 @@ public: /// Gets the scheduler for the CPU core with the specified index const Kernel::Scheduler& Scheduler(std::size_t core_index) const; + /// Gets the global scheduler + Kernel::GlobalScheduler& GlobalScheduler(); + + /// Gets the global scheduler + const Kernel::GlobalScheduler& GlobalScheduler() const; + /// Provides a pointer to the current process Kernel::Process* CurrentProcess(); diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 799e5e0d8..b4fd1d3f3 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -18,6 +18,7 @@ #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/resource_limit.h" +#include "core/hle/kernel/scheduler.h" #include "core/hle/kernel/thread.h" #include "core/hle/lock.h" #include "core/hle/result.h" @@ -140,6 +141,7 @@ struct KernelCore::Impl { // Lists all processes that exist in the current session. std::vector> process_list; Process* current_process = nullptr; + Kernel::GlobalScheduler global_scheduler; SharedPtr system_resource_limit; @@ -203,6 +205,14 @@ const std::vector>& KernelCore::GetProcessList() const { return impl->process_list; } +Kernel::GlobalScheduler& KernelCore::GlobalScheduler() { + return impl->global_scheduler; +} + +const Kernel::GlobalScheduler& KernelCore::GlobalScheduler() const { + return impl->global_scheduler; +} + void KernelCore::AddNamedPort(std::string name, SharedPtr port) { impl->named_ports.emplace(std::move(name), std::move(port)); } diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 0cc44ee76..f9f5bdc88 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -25,6 +25,7 @@ class HandleTable; class Process; class ResourceLimit; class Thread; +class GlobalScheduler; /// Represents a single instance of the kernel. class KernelCore { @@ -75,6 +76,12 @@ public: /// Retrieves the list of processes. const std::vector>& GetProcessList() const; + /// Gets the sole instance of the global scheduler + Kernel::GlobalScheduler& GlobalScheduler(); + + /// Gets the sole instance of the global scheduler + const Kernel::GlobalScheduler& GlobalScheduler() const; + /// Adds a port to the named port table void AddNamedPort(std::string name, SharedPtr port);