scheduler: Amend documentation comments
Adjusts the formatting of a few of the comments an ensures they get recognized as proper Doxygen comments.
This commit is contained in:
parent
4c5731c34f
commit
2dc469ceba
@ -35,24 +35,11 @@ void GlobalScheduler::RemoveThread(const Thread* thread) {
|
|||||||
thread_list.end());
|
thread_list.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* UnloadThread selects a core and forces it to unload its current thread's context
|
|
||||||
*/
|
|
||||||
void GlobalScheduler::UnloadThread(s32 core) {
|
void GlobalScheduler::UnloadThread(s32 core) {
|
||||||
Scheduler& sched = system.Scheduler(core);
|
Scheduler& sched = system.Scheduler(core);
|
||||||
sched.UnloadThread();
|
sched.UnloadThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* SelectThread takes care of selecting the new scheduled thread.
|
|
||||||
* It does it in 3 steps:
|
|
||||||
* - First a thread is selected from the top of the priority queue. If no thread
|
|
||||||
* is obtained then we move to step two, else we are done.
|
|
||||||
* - Second we try to get a suggested thread that's not assigned to any core or
|
|
||||||
* that is not the top thread in that core.
|
|
||||||
* - Third is no suggested thread is found, we do a second pass and pick a running
|
|
||||||
* thread in another core and swap it with its current thread.
|
|
||||||
*/
|
|
||||||
void GlobalScheduler::SelectThread(u32 core) {
|
void GlobalScheduler::SelectThread(u32 core) {
|
||||||
const auto update_thread = [](Thread* thread, Scheduler& sched) {
|
const auto update_thread = [](Thread* thread, Scheduler& sched) {
|
||||||
if (thread != sched.selected_thread) {
|
if (thread != sched.selected_thread) {
|
||||||
@ -114,10 +101,6 @@ void GlobalScheduler::SelectThread(u32 core) {
|
|||||||
update_thread(current_thread, sched);
|
update_thread(current_thread, sched);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* YieldThread takes a thread and moves it to the back of the it's priority list
|
|
||||||
* This operation can be redundant and no scheduling is changed if marked as so.
|
|
||||||
*/
|
|
||||||
bool GlobalScheduler::YieldThread(Thread* yielding_thread) {
|
bool GlobalScheduler::YieldThread(Thread* yielding_thread) {
|
||||||
// Note: caller should use critical section, etc.
|
// Note: caller should use critical section, etc.
|
||||||
const u32 core_id = static_cast<u32>(yielding_thread->GetProcessorID());
|
const u32 core_id = static_cast<u32>(yielding_thread->GetProcessorID());
|
||||||
@ -132,12 +115,6 @@ bool GlobalScheduler::YieldThread(Thread* yielding_thread) {
|
|||||||
return AskForReselectionOrMarkRedundant(yielding_thread, winner);
|
return AskForReselectionOrMarkRedundant(yielding_thread, winner);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* YieldThreadAndBalanceLoad takes a thread and moves it to the back of the it's priority list.
|
|
||||||
* Afterwards, tries to pick a suggested thread from the suggested queue that has worse time or
|
|
||||||
* a better priority than the next thread in the core.
|
|
||||||
* This operation can be redundant and no scheduling is changed if marked as so.
|
|
||||||
*/
|
|
||||||
bool GlobalScheduler::YieldThreadAndBalanceLoad(Thread* yielding_thread) {
|
bool GlobalScheduler::YieldThreadAndBalanceLoad(Thread* yielding_thread) {
|
||||||
// Note: caller should check if !thread.IsSchedulerOperationRedundant and use critical section,
|
// Note: caller should check if !thread.IsSchedulerOperationRedundant and use critical section,
|
||||||
// etc.
|
// etc.
|
||||||
@ -189,12 +166,6 @@ bool GlobalScheduler::YieldThreadAndBalanceLoad(Thread* yielding_thread) {
|
|||||||
return AskForReselectionOrMarkRedundant(yielding_thread, winner);
|
return AskForReselectionOrMarkRedundant(yielding_thread, winner);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* YieldThreadAndWaitForLoadBalancing takes a thread and moves it out of the scheduling queue
|
|
||||||
* and into the suggested queue. If no thread can be squeduled afterwards in that core,
|
|
||||||
* a suggested thread is obtained instead.
|
|
||||||
* This operation can be redundant and no scheduling is changed if marked as so.
|
|
||||||
*/
|
|
||||||
bool GlobalScheduler::YieldThreadAndWaitForLoadBalancing(Thread* yielding_thread) {
|
bool GlobalScheduler::YieldThreadAndWaitForLoadBalancing(Thread* yielding_thread) {
|
||||||
// Note: caller should check if !thread.IsSchedulerOperationRedundant and use critical section,
|
// Note: caller should check if !thread.IsSchedulerOperationRedundant and use critical section,
|
||||||
// etc.
|
// etc.
|
||||||
|
@ -26,6 +26,7 @@ public:
|
|||||||
|
|
||||||
explicit GlobalScheduler(Core::System& system);
|
explicit GlobalScheduler(Core::System& system);
|
||||||
~GlobalScheduler();
|
~GlobalScheduler();
|
||||||
|
|
||||||
/// Adds a new thread to the scheduler
|
/// Adds a new thread to the scheduler
|
||||||
void AddThread(SharedPtr<Thread> thread);
|
void AddThread(SharedPtr<Thread> thread);
|
||||||
|
|
||||||
@ -37,47 +38,57 @@ public:
|
|||||||
return thread_list;
|
return thread_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a thread to the suggested queue of a cpu core. Suggested threads may be
|
/**
|
||||||
// picked if no thread is scheduled to run on the core.
|
* Add a thread to the suggested queue of a cpu core. Suggested threads may be
|
||||||
|
* picked if no thread is scheduled to run on the core.
|
||||||
|
*/
|
||||||
void Suggest(u32 priority, u32 core, Thread* thread);
|
void Suggest(u32 priority, u32 core, Thread* thread);
|
||||||
|
|
||||||
// Remove a thread to the suggested queue of a cpu core. Suggested threads may be
|
/**
|
||||||
// picked if no thread is scheduled to run on the core.
|
* Remove a thread to the suggested queue of a cpu core. Suggested threads may be
|
||||||
|
* picked if no thread is scheduled to run on the core.
|
||||||
|
*/
|
||||||
void Unsuggest(u32 priority, u32 core, Thread* thread);
|
void Unsuggest(u32 priority, u32 core, Thread* thread);
|
||||||
|
|
||||||
// Add a thread to the scheduling queue of a cpu core. The thread is added at the
|
/**
|
||||||
// back the queue in its priority level
|
* Add a thread to the scheduling queue of a cpu core. The thread is added at the
|
||||||
|
* back the queue in its priority level.
|
||||||
|
*/
|
||||||
void Schedule(u32 priority, u32 core, Thread* thread);
|
void Schedule(u32 priority, u32 core, Thread* thread);
|
||||||
|
|
||||||
// Add a thread to the scheduling queue of a cpu core. The thread is added at the
|
/**
|
||||||
// front the queue in its priority level
|
* Add a thread to the scheduling queue of a cpu core. The thread is added at the
|
||||||
|
* front the queue in its priority level.
|
||||||
|
*/
|
||||||
void SchedulePrepend(u32 priority, u32 core, Thread* thread);
|
void SchedulePrepend(u32 priority, u32 core, Thread* thread);
|
||||||
|
|
||||||
// Reschedule an already scheduled thread based on a new priority
|
/// Reschedule an already scheduled thread based on a new priority
|
||||||
void Reschedule(u32 priority, u32 core, Thread* thread);
|
void Reschedule(u32 priority, u32 core, Thread* thread);
|
||||||
|
|
||||||
// Unschedule a thread.
|
/// Unschedules a thread.
|
||||||
void Unschedule(u32 priority, u32 core, Thread* thread);
|
void Unschedule(u32 priority, u32 core, Thread* thread);
|
||||||
|
|
||||||
// Transfers a thread into an specific core. If the destination_core is -1
|
/**
|
||||||
// it will be unscheduled from its source code and added into its suggested
|
* Transfers a thread into an specific core. If the destination_core is -1
|
||||||
// queue.
|
* it will be unscheduled from its source code and added into its suggested
|
||||||
|
* queue.
|
||||||
|
*/
|
||||||
void TransferToCore(u32 priority, s32 destination_core, Thread* thread);
|
void TransferToCore(u32 priority, s32 destination_core, Thread* thread);
|
||||||
|
|
||||||
/*
|
/// Selects a core and forces it to unload its current thread's context
|
||||||
* UnloadThread selects a core and forces it to unload its current thread's context
|
|
||||||
*/
|
|
||||||
void UnloadThread(s32 core);
|
void UnloadThread(s32 core);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* SelectThread takes care of selecting the new scheduled thread.
|
* Takes care of selecting the new scheduled thread in three steps:
|
||||||
* It does it in 3 steps:
|
*
|
||||||
* - First a thread is selected from the top of the priority queue. If no thread
|
* 1. First a thread is selected from the top of the priority queue. If no thread
|
||||||
* is obtained then we move to step two, else we are done.
|
* is obtained then we move to step two, else we are done.
|
||||||
* - Second we try to get a suggested thread that's not assigned to any core or
|
*
|
||||||
* that is not the top thread in that core.
|
* 2. Second we try to get a suggested thread that's not assigned to any core or
|
||||||
* - Third is no suggested thread is found, we do a second pass and pick a running
|
* that is not the top thread in that core.
|
||||||
* thread in another core and swap it with its current thread.
|
*
|
||||||
|
* 3. Third is no suggested thread is found, we do a second pass and pick a running
|
||||||
|
* thread in another core and swap it with its current thread.
|
||||||
*/
|
*/
|
||||||
void SelectThread(u32 core);
|
void SelectThread(u32 core);
|
||||||
|
|
||||||
@ -85,33 +96,37 @@ public:
|
|||||||
return !scheduled_queue[core_id].empty();
|
return !scheduled_queue[core_id].empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* YieldThread takes a thread and moves it to the back of the it's priority list
|
* Takes a thread and moves it to the back of the it's priority list.
|
||||||
* This operation can be redundant and no scheduling is changed if marked as so.
|
*
|
||||||
|
* @note This operation can be redundant and no scheduling is changed if marked as so.
|
||||||
*/
|
*/
|
||||||
bool YieldThread(Thread* thread);
|
bool YieldThread(Thread* thread);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* YieldThreadAndBalanceLoad takes a thread and moves it to the back of the it's priority list.
|
* Takes a thread and moves it to the back of the it's priority list.
|
||||||
* Afterwards, tries to pick a suggested thread from the suggested queue that has worse time or
|
* Afterwards, tries to pick a suggested thread from the suggested queue that has worse time or
|
||||||
* a better priority than the next thread in the core.
|
* a better priority than the next thread in the core.
|
||||||
* This operation can be redundant and no scheduling is changed if marked as so.
|
*
|
||||||
|
* @note This operation can be redundant and no scheduling is changed if marked as so.
|
||||||
*/
|
*/
|
||||||
bool YieldThreadAndBalanceLoad(Thread* thread);
|
bool YieldThreadAndBalanceLoad(Thread* thread);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* YieldThreadAndWaitForLoadBalancing takes a thread and moves it out of the scheduling queue
|
* Takes a thread and moves it out of the scheduling queue.
|
||||||
* and into the suggested queue. If no thread can be squeduled afterwards in that core,
|
* and into the suggested queue. If no thread can be scheduled afterwards in that core,
|
||||||
* a suggested thread is obtained instead.
|
* a suggested thread is obtained instead.
|
||||||
* This operation can be redundant and no scheduling is changed if marked as so.
|
*
|
||||||
|
* @note This operation can be redundant and no scheduling is changed if marked as so.
|
||||||
*/
|
*/
|
||||||
bool YieldThreadAndWaitForLoadBalancing(Thread* thread);
|
bool YieldThreadAndWaitForLoadBalancing(Thread* thread);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* PreemptThreads this operation rotates the scheduling queues of threads at
|
* Rotates the scheduling queues of threads at a preemption priority and then does
|
||||||
* a preemption priority and then does some core rebalancing. Preemption priorities
|
* some core rebalancing. Preemption priorities can be found in the array
|
||||||
* can be found in the array 'preemption_priorities'. This operation happens
|
* 'preemption_priorities'.
|
||||||
* every 10ms.
|
*
|
||||||
|
* @note This operation happens every 10ms.
|
||||||
*/
|
*/
|
||||||
void PreemptThreads();
|
void PreemptThreads();
|
||||||
|
|
||||||
@ -137,8 +152,8 @@ private:
|
|||||||
std::array<Common::MultiLevelQueue<Thread*, THREADPRIO_COUNT>, NUM_CPU_CORES> suggested_queue;
|
std::array<Common::MultiLevelQueue<Thread*, THREADPRIO_COUNT>, NUM_CPU_CORES> suggested_queue;
|
||||||
std::atomic<bool> is_reselection_pending;
|
std::atomic<bool> is_reselection_pending;
|
||||||
|
|
||||||
// `preemption_priorities` are the priority levels at which the global scheduler
|
// The priority levels at which the global scheduler preempts threads every 10 ms. They are
|
||||||
// preempts threads every 10 ms. They are ordered from Core 0 to Core 3
|
// ordered from Core 0 to Core 3.
|
||||||
std::array<u32, NUM_CPU_CORES> preemption_priorities = {59, 59, 59, 62};
|
std::array<u32, NUM_CPU_CORES> preemption_priorities = {59, 59, 59, 62};
|
||||||
|
|
||||||
/// Lists all thread ids that aren't deleted/etc.
|
/// Lists all thread ids that aren't deleted/etc.
|
||||||
@ -181,10 +196,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class GlobalScheduler;
|
friend class GlobalScheduler;
|
||||||
/**
|
|
||||||
* Switches the CPU's active thread context to that of the specified thread
|
/// Switches the CPU's active thread context to that of the specified thread
|
||||||
* @param new_thread The thread to switch to
|
|
||||||
*/
|
|
||||||
void SwitchContext();
|
void SwitchContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user