kernel/scheduler: Pass in system instance in constructor

Avoids directly relying on the global system instance and instead makes
an arbitrary system instance an explicit dependency on construction.

This also allows removing dependencies on some global accessor functions
as well.
This commit is contained in:
Lioncash 2019-03-04 16:02:59 -05:00
parent 07e13d6728
commit fad20213e6
5 changed files with 23 additions and 17 deletions

View file

@ -13,7 +13,8 @@
namespace Core {
class ARM_Interface;
}
class System;
} // namespace Core
namespace Kernel {
@ -21,7 +22,7 @@ class Process;
class Scheduler final {
public:
explicit Scheduler(Core::ARM_Interface& cpu_core);
explicit Scheduler(Core::System& system, Core::ARM_Interface& cpu_core);
~Scheduler();
/// Returns whether there are any threads that are ready to run.
@ -162,6 +163,7 @@ private:
Core::ARM_Interface& cpu_core;
u64 last_context_switch_time = 0;
Core::System& system;
static std::mutex scheduler_mutex;
};