Mark3 Realtime Kernel
Mark3::Scheduler Class Reference

The Scheduler Class. This class provides priority-based round-robin Thread scheduling for all active threads managed by the kernel. More...

#include <scheduler.h>

Static Public Member Functions

static void Init ()
 Init Intiailize the scheduler, must be called before use. More...
 
static void Schedule ()
 Schedule Run the scheduler, determines the next thread to run based on the current state of the threads. Note that the next-thread chosen from this function is only valid while in a critical section. More...
 
static void Add (Thread *pclThread_)
 Add Add a thread to the scheduler at its current priority level. More...
 
static void Remove (Thread *pclThread_)
 Remove Remove a thread from the scheduler at its current priority level. More...
 
static bool SetScheduler (bool bEnable_)
 SetScheduler Set the active state of the scheduler. When the scheduler is disabled, the next thread is never set; the currently running thread will run forever until the scheduler is enabled again. Care must be taken to ensure that we don't end up trying to block while the scheduler is disabled, otherwise the system ends up in an unusable state. More...
 
static ThreadGetCurrentThread ()
 GetCurrentThread Return the pointer to the currently-running thread. More...
 
static volatile ThreadGetNextThread ()
 GetNextThread Return the pointer to the thread that should run next, according to the last run of the scheduler. More...
 
static ThreadListGetThreadList (PORT_PRIO_TYPE uXPriority_)
 GetThreadList Return the pointer to the active list of threads that are at the given priority level in the scheduler. More...
 
static ThreadListGetStopList ()
 GetStopList Return the pointer to the list of threads that are in the scheduler's stopped state. More...
 
static bool IsEnabled ()
 IsEnabled Return the current state of the scheduler - whether or not scheudling is enabled or disabled. More...
 
static void QueueScheduler ()
 QueueScheduler Tell the kernel to perform a scheduling operation as soon as the scheduler is re-enabled. More...
 

Static Private Attributes

static constexpr auto m_uNumPriorities = size_t { KERNEL_NUM_PRIORITIES }
 
static bool m_bEnabled
 Scheduler's state - enabled or disabled. More...
 
static bool m_bQueuedSchedule
 Variable representing whether or not there's a queued scheduler operation. More...
 
static ThreadList m_clStopList
 ThreadList for all stopped threads. More...
 
static ThreadList m_aclPriorities [m_uNumPriorities]
 ThreadLists for all threads at all priorities. More...
 
static PriorityMap m_clPrioMap
 Priority bitmap lookup structure, 1-bit per thread priority. More...
 

Detailed Description

The Scheduler Class. This class provides priority-based round-robin Thread scheduling for all active threads managed by the kernel.

Definition at line 63 of file scheduler.h.

Member Function Documentation

◆ Add()

void Mark3::Scheduler::Add ( Thread pclThread_)
static

Add Add a thread to the scheduler at its current priority level.

Parameters
pclThread_Pointer to the thread to add to the scheduler

Definition at line 59 of file scheduler.cpp.

◆ GetCurrentThread()

static Thread* Mark3::Scheduler::GetCurrentThread ( )
inlinestatic

GetCurrentThread Return the pointer to the currently-running thread.

Returns
Pointer to the currently-running thread
Examples:
lab9_dynamic_threads/main.cpp.

Definition at line 116 of file scheduler.h.

◆ GetNextThread()

static volatile Thread* Mark3::Scheduler::GetNextThread ( )
inlinestatic

GetNextThread Return the pointer to the thread that should run next, according to the last run of the scheduler.

Returns
Pointer to the next-running thread

Definition at line 124 of file scheduler.h.

◆ GetStopList()

static ThreadList* Mark3::Scheduler::GetStopList ( )
inlinestatic

GetStopList Return the pointer to the list of threads that are in the scheduler's stopped state.

Returns
Pointer to the ThreadList containing the stopped threads

Definition at line 142 of file scheduler.h.

◆ GetThreadList()

static ThreadList* Mark3::Scheduler::GetThreadList ( PORT_PRIO_TYPE  uXPriority_)
inlinestatic

GetThreadList Return the pointer to the active list of threads that are at the given priority level in the scheduler.

Parameters
uXPriority_Priority level of the threadlist
Returns
Pointer to the ThreadList for the given priority level

Definition at line 134 of file scheduler.h.

◆ Init()

void Mark3::Scheduler::Init ( void  )
static

Init Intiailize the scheduler, must be called before use.

Definition at line 36 of file scheduler.cpp.

◆ IsEnabled()

static bool Mark3::Scheduler::IsEnabled ( )
inlinestatic

IsEnabled Return the current state of the scheduler - whether or not scheudling is enabled or disabled.

Returns
true - scheduler enabled, false - disabled

Definition at line 150 of file scheduler.h.

◆ QueueScheduler()

static void Mark3::Scheduler::QueueScheduler ( )
inlinestatic

QueueScheduler Tell the kernel to perform a scheduling operation as soon as the scheduler is re-enabled.

Definition at line 156 of file scheduler.h.

◆ Remove()

void Mark3::Scheduler::Remove ( Thread pclThread_)
static

Remove Remove a thread from the scheduler at its current priority level.

Parameters
pclThread_Pointer to the thread to be removed from the scheduler

Definition at line 67 of file scheduler.cpp.

◆ Schedule()

void Mark3::Scheduler::Schedule ( )
static

Schedule Run the scheduler, determines the next thread to run based on the current state of the threads. Note that the next-thread chosen from this function is only valid while in a critical section.

Definition at line 45 of file scheduler.cpp.

◆ SetScheduler()

bool Mark3::Scheduler::SetScheduler ( bool  bEnable_)
static

SetScheduler Set the active state of the scheduler. When the scheduler is disabled, the next thread is never set; the currently running thread will run forever until the scheduler is enabled again. Care must be taken to ensure that we don't end up trying to block while the scheduler is disabled, otherwise the system ends up in an unusable state.

Parameters
bEnable_true to enable, false to disable the scheduler

Definition at line 75 of file scheduler.cpp.

Member Data Documentation

◆ m_aclPriorities

ThreadList Mark3::Scheduler::m_aclPriorities
staticprivate

ThreadLists for all threads at all priorities.

Definition at line 171 of file scheduler.h.

◆ m_bEnabled

bool Mark3::Scheduler::m_bEnabled
staticprivate

Scheduler's state - enabled or disabled.

Definition at line 162 of file scheduler.h.

◆ m_bQueuedSchedule

bool Mark3::Scheduler::m_bQueuedSchedule
staticprivate

Variable representing whether or not there's a queued scheduler operation.

Definition at line 165 of file scheduler.h.

◆ m_clPrioMap

PriorityMap Mark3::Scheduler::m_clPrioMap
staticprivate

Priority bitmap lookup structure, 1-bit per thread priority.

Definition at line 174 of file scheduler.h.

◆ m_clStopList

ThreadList Mark3::Scheduler::m_clStopList
staticprivate

ThreadList for all stopped threads.

Definition at line 168 of file scheduler.h.

◆ m_uNumPriorities

constexpr auto Mark3::Scheduler::m_uNumPriorities = size_t { KERNEL_NUM_PRIORITIES }
staticprivate

Definition at line 159 of file scheduler.h.


The documentation for this class was generated from the following files: