mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-24 19:54:22 -04:00
kern: implement KSchedulerLock
This commit is contained in:
parent
797c04d19f
commit
57222e8301
4 changed files with 160 additions and 0 deletions
|
@ -17,6 +17,7 @@
|
|||
#include <mesosphere/kern_select_cpu.hpp>
|
||||
#include <mesosphere/kern_k_thread.hpp>
|
||||
#include <mesosphere/kern_k_priority_queue.hpp>
|
||||
#include <mesosphere/kern_k_scheduler_lock.hpp>
|
||||
|
||||
namespace ams::kern {
|
||||
|
||||
|
@ -25,10 +26,14 @@ namespace ams::kern {
|
|||
static_assert(KSchedulerPriorityQueue::NumCores == cpu::NumCores);
|
||||
static_assert(KSchedulerPriorityQueue::NumPriority == BITSIZEOF(u64));
|
||||
|
||||
class KScopedSchedulerLock;
|
||||
|
||||
class KScheduler {
|
||||
NON_COPYABLE(KScheduler);
|
||||
NON_MOVEABLE(KScheduler);
|
||||
public:
|
||||
using LockType = KAbstractSchedulerLock<KScheduler>;
|
||||
|
||||
struct SchedulingState {
|
||||
std::atomic<bool> needs_scheduling;
|
||||
bool interrupt_task_thread_runnable;
|
||||
|
@ -37,6 +42,9 @@ namespace ams::kern {
|
|||
KThread *highest_priority_thread;
|
||||
void *idle_thread_stack;
|
||||
};
|
||||
private:
|
||||
friend class KScopedSchedulerLock;
|
||||
static inline LockType s_scheduler_lock;
|
||||
private:
|
||||
SchedulingState state;
|
||||
bool is_active;
|
||||
|
@ -47,6 +55,18 @@ namespace ams::kern {
|
|||
public:
|
||||
KScheduler();
|
||||
/* TODO: Actually implement KScheduler. This is a placeholder. */
|
||||
public:
|
||||
/* API used by KSchedulerLock */
|
||||
static void DisableScheduling();
|
||||
static void EnableScheduling();
|
||||
static u64 UpdateHighestPriorityThreads();
|
||||
static void EnableSchedulingAndSchedule(u64 cores_needing_scheduling);
|
||||
};
|
||||
|
||||
class KScopedSchedulerLock {
|
||||
public:
|
||||
ALWAYS_INLINE KScopedSchedulerLock() { KScheduler::s_scheduler_lock.Lock(); }
|
||||
ALWAYS_INLINE ~KScopedSchedulerLock() { KScheduler::s_scheduler_lock.Unlock(); }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue