mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-12-27 19:45:43 +00:00
Kernel: Make global scheduler depend on KernelCore
This commit is contained in:
parent
d4da52bbd9
commit
0728dfef84
|
@ -97,8 +97,8 @@ static void ThreadWakeupCallback(u64 thread_handle, [[maybe_unused]] s64 cycles_
|
||||||
}
|
}
|
||||||
|
|
||||||
struct KernelCore::Impl {
|
struct KernelCore::Impl {
|
||||||
explicit Impl(Core::System& system)
|
explicit Impl(Core::System& system, KernelCore& kernel)
|
||||||
: system{system}, global_scheduler{system}, synchronization{system} {}
|
: system{system}, global_scheduler{kernel}, synchronization{system} {}
|
||||||
|
|
||||||
void Initialize(KernelCore& kernel) {
|
void Initialize(KernelCore& kernel) {
|
||||||
Shutdown();
|
Shutdown();
|
||||||
|
@ -215,7 +215,7 @@ struct KernelCore::Impl {
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
};
|
};
|
||||||
|
|
||||||
KernelCore::KernelCore(Core::System& system) : impl{std::make_unique<Impl>(system)} {}
|
KernelCore::KernelCore(Core::System& system) : impl{std::make_unique<Impl>(system, *this)} {}
|
||||||
KernelCore::~KernelCore() {
|
KernelCore::~KernelCore() {
|
||||||
Shutdown();
|
Shutdown();
|
||||||
}
|
}
|
||||||
|
@ -265,6 +265,14 @@ const Kernel::GlobalScheduler& KernelCore::GlobalScheduler() const {
|
||||||
return impl->global_scheduler;
|
return impl->global_scheduler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Kernel::Scheduler& KernelCore::Scheduler(std::size_t id) {
|
||||||
|
return impl->cores[id].Scheduler();
|
||||||
|
}
|
||||||
|
|
||||||
|
const Kernel::Scheduler& KernelCore::Scheduler(std::size_t id) const {
|
||||||
|
return impl->cores[id].Scheduler();
|
||||||
|
}
|
||||||
|
|
||||||
Kernel::PhysicalCore& KernelCore::PhysicalCore(std::size_t id) {
|
Kernel::PhysicalCore& KernelCore::PhysicalCore(std::size_t id) {
|
||||||
return impl->cores[id];
|
return impl->cores[id];
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ class HandleTable;
|
||||||
class PhysicalCore;
|
class PhysicalCore;
|
||||||
class Process;
|
class Process;
|
||||||
class ResourceLimit;
|
class ResourceLimit;
|
||||||
|
class Scheduler;
|
||||||
class Synchronization;
|
class Synchronization;
|
||||||
class Thread;
|
class Thread;
|
||||||
|
|
||||||
|
@ -87,6 +88,12 @@ public:
|
||||||
/// Gets the sole instance of the global scheduler
|
/// Gets the sole instance of the global scheduler
|
||||||
const Kernel::GlobalScheduler& GlobalScheduler() const;
|
const Kernel::GlobalScheduler& GlobalScheduler() const;
|
||||||
|
|
||||||
|
/// Gets the sole instance of the Scheduler assoviated with cpu core 'id'
|
||||||
|
Kernel::Scheduler& Scheduler(std::size_t id);
|
||||||
|
|
||||||
|
/// Gets the sole instance of the Scheduler assoviated with cpu core 'id'
|
||||||
|
const Kernel::Scheduler& Scheduler(std::size_t id) const;
|
||||||
|
|
||||||
/// Gets the an instance of the respective physical CPU core.
|
/// Gets the an instance of the respective physical CPU core.
|
||||||
Kernel::PhysicalCore& PhysicalCore(std::size_t id);
|
Kernel::PhysicalCore& PhysicalCore(std::size_t id);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
GlobalScheduler::GlobalScheduler(Core::System& system) : system{system} {}
|
GlobalScheduler::GlobalScheduler(KernelCore& kernel) : kernel{kernel} {}
|
||||||
|
|
||||||
GlobalScheduler::~GlobalScheduler() = default;
|
GlobalScheduler::~GlobalScheduler() = default;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ void GlobalScheduler::RemoveThread(std::shared_ptr<Thread> thread) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalScheduler::UnloadThread(std::size_t core) {
|
void GlobalScheduler::UnloadThread(std::size_t core) {
|
||||||
Scheduler& sched = system.Scheduler(core);
|
Scheduler& sched = kernel.Scheduler(core);
|
||||||
sched.UnloadThread();
|
sched.UnloadThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ void GlobalScheduler::SelectThread(std::size_t core) {
|
||||||
sched.is_context_switch_pending = sched.selected_thread != sched.current_thread;
|
sched.is_context_switch_pending = sched.selected_thread != sched.current_thread;
|
||||||
std::atomic_thread_fence(std::memory_order_seq_cst);
|
std::atomic_thread_fence(std::memory_order_seq_cst);
|
||||||
};
|
};
|
||||||
Scheduler& sched = system.Scheduler(core);
|
Scheduler& sched = kernel.Scheduler(core);
|
||||||
Thread* current_thread = nullptr;
|
Thread* current_thread = nullptr;
|
||||||
// Step 1: Get top thread in schedule queue.
|
// Step 1: Get top thread in schedule queue.
|
||||||
current_thread = scheduled_queue[core].empty() ? nullptr : scheduled_queue[core].front();
|
current_thread = scheduled_queue[core].empty() ? nullptr : scheduled_queue[core].front();
|
||||||
|
|
|
@ -20,11 +20,12 @@ class System;
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
|
class KernelCore;
|
||||||
class Process;
|
class Process;
|
||||||
|
|
||||||
class GlobalScheduler final {
|
class GlobalScheduler final {
|
||||||
public:
|
public:
|
||||||
explicit GlobalScheduler(Core::System& system);
|
explicit GlobalScheduler(KernelCore& kernel);
|
||||||
~GlobalScheduler();
|
~GlobalScheduler();
|
||||||
|
|
||||||
/// Adds a new thread to the scheduler
|
/// Adds a new thread to the scheduler
|
||||||
|
@ -160,7 +161,7 @@ private:
|
||||||
|
|
||||||
/// Lists all thread ids that aren't deleted/etc.
|
/// Lists all thread ids that aren't deleted/etc.
|
||||||
std::vector<std::shared_ptr<Thread>> thread_list;
|
std::vector<std::shared_ptr<Thread>> thread_list;
|
||||||
Core::System& system;
|
KernelCore& kernel;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Scheduler final {
|
class Scheduler final {
|
||||||
|
|
Loading…
Reference in a new issue