RTEMS CPU Kit with SuperCore  4.11.3
Modules | Files | Data Structures | Macros | Typedefs | Functions | Variables
Scheduler Handler

This handler encapsulates functionality related to managing sets of threads that are ready for execution. More...

Collaboration diagram for Scheduler Handler:

Modules

 CBS Scheduler
 
 EDF Scheduler
 
 Deterministic Priority Scheduler
 
 Simple Priority Scheduler
 
 SMP Scheduler
 The scheduler nodes can be in four states.
 

Files

file  scheduler.c
 Scheduler Initialize.
 
file  schedulercbs.c
 CBS Scheduler Budget Handler.
 
file  schedulercbsattachthread.c
 Attach Scheduler CBS Thread.
 
file  schedulercbscleanup.c
 Scheduler CBS Cleanup.
 
file  schedulercbscreateserver.c
 Scheduler CBS Create Server.
 
file  schedulercbsdestroyserver.c
 Scheduler CBS Destroy Server.
 
file  schedulercbsdetachthread.c
 Detach from the CBS Server.
 
file  schedulercbsgetapprovedbudget.c
 Scheduler CBS Get Approved Budget.
 
file  schedulercbsgetexecutiontime.c
 Get Thread Execution Info.
 
file  schedulercbsgetparameters.c
 _Scheduler_CBS_Get_parameters
 
file  schedulercbsgetremainingbudget.c
 Scheduler CBS Get Remaining Budget.
 
file  schedulercbsgetserverid.c
 Scheduler CBS Get Server id.
 
file  schedulercbsreleasejob.c
 Scheduler CBS Release Job.
 
file  schedulercbssetparameters.c
 Set Parameters for CBS Scheduling.
 
file  schedulercbsunblock.c
 Unblocks a Thread from the Queue.
 
file  schedulerdefaultgetaffinity.c
 Scheduler Default Get Affinity Operation.
 
file  schedulerdefaultnodedestroy.c
 Scheduler Default Node Destruction Operation.
 
file  schedulerdefaultnodeinit.c
 Scheduler Default Node Initialization Operation.
 
file  schedulerdefaultreleasejob.c
 Default Scheduler Release Job Operation.
 
file  schedulerdefaultsetaffinity.c
 Scheduler Default Set Affinity Operation.
 
file  schedulerdefaulttick.c
 Default Scheduler At Tick Handler.
 
file  schedulerdefaultupdate.c
 Scheduler Default Update Operation.
 
file  scheduleredf.c
 Scheduler EDF Initialize and Support.
 
file  scheduleredfblock.c
 Removes the Thread from Ready Queue.
 
file  scheduleredfchangepriority.c
 Scheduler EDF Extract.
 
file  scheduleredfnodeinit.c
 Scheduler EDF Allocate.
 
file  scheduleredfprioritycompare.c
 Compares Priorities of Threads.
 
file  scheduleredfreleasejob.c
 Scheduler EDF Release Job.
 
file  scheduleredfschedule.c
 Scheduler EDF Allocate.
 
file  scheduleredfunblock.c
 Scheduler EDF Unblock.
 
file  scheduleredfupdate.c
 Scheduler EDF Update.
 
file  scheduleredfyield.c
 Scheduler EDF Yield.
 
file  schedulerpriorityblock.c
 Scheduler Priority Block.
 
file  schedulerprioritychangepriority.c
 Removes Thread from Thread Queue.
 
file  schedulerpriorityprioritycompare.c
 Scheduler Priority Compare Two Priorities.
 
file  schedulerpriorityschedule.c
 Priority Scheduler Schedule Method.
 
file  schedulerpriorityunblock.c
 Scheduler Priority Unblock.
 
file  schedulerpriorityupdate.c
 Update Scheduler Priority.
 
file  schedulerpriorityyield.c
 Scheduler Priority Yield.
 
file  schedulersimple.c
 Scheduler Simple Functions.
 
file  schedulersimpleblock.c
 Simple Scheduler Block a Thread.
 
file  schedulersimplechangepriority.c
 Removes a Thread from the Simple Queue.
 
file  schedulersimpleschedule.c
 Simple Schedule Determine Heir.
 
file  schedulersimpleunblock.c
 Scheduler Simple Handler / Unblock.
 
file  schedulersimpleyield.c
 Simple Schedule Yield CPU.
 
file  schedulersmpdebug.c
 Scheduler SMP Debug Implementation.
 

Data Structures

struct  Scheduler_Operations
 The scheduler operations. More...
 
struct  Scheduler_Context
 Scheduler context. More...
 
struct  Scheduler_Control
 Scheduler control. More...
 
struct  Scheduler_Node
 Scheduler node for per-thread data. More...
 

Macros

#define SCHEDULER_RETURN_VOID_OR_NULL   return
 
#define _Scheduler_Count   ( (size_t) 1 )
 Count of registered schedulers. More...
 
#define SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP
 
#define SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY
 

Typedefs

typedef struct Scheduler_Control Scheduler_Control
 
typedef struct Scheduler_Node Scheduler_Node
 
typedef void Scheduler_Void_or_thread
 
typedef struct Scheduler_Context Scheduler_Context
 Scheduler context. More...
 

Functions

void _Scheduler_default_Schedule (const Scheduler_Control *scheduler, Thread_Control *the_thread)
 Does nothing. More...
 
void _Scheduler_default_Node_initialize (const Scheduler_Control *scheduler, Thread_Control *the_thread)
 Does nothing. More...
 
void _Scheduler_default_Node_destroy (const Scheduler_Control *scheduler, Thread_Control *the_thread)
 Does nothing. More...
 
void _Scheduler_default_Update_priority (const Scheduler_Control *scheduler, Thread_Control *the_thread, Priority_Control new_priority)
 Does nothing. More...
 
void _Scheduler_default_Release_job (const Scheduler_Control *scheduler, Thread_Control *the_thread, uint32_t deadline)
 Does nothing. More...
 
void _Scheduler_default_Tick (const Scheduler_Control *scheduler, Thread_Control *executing)
 Performs tick operations depending on the CPU budget algorithm for each executing thread. More...
 
void _Scheduler_default_Start_idle (const Scheduler_Control *scheduler, Thread_Control *the_thread, struct Per_CPU_Control *cpu)
 Starts an idle thread. More...
 
void _Scheduler_Handler_initialization (void)
 Initializes the scheduler to the policy chosen by the user. More...
 
RTEMS_INLINE_ROUTINE Scheduler_Context_Scheduler_Get_context (const Scheduler_Control *scheduler)
 
RTEMS_INLINE_ROUTINE const Scheduler_Control_Scheduler_Get (const Thread_Control *the_thread)
 
RTEMS_INLINE_ROUTINE const Scheduler_Control_Scheduler_Get_own (const Thread_Control *the_thread)
 
RTEMS_INLINE_ROUTINE const Scheduler_Control_Scheduler_Get_by_CPU_index (uint32_t cpu_index)
 
RTEMS_INLINE_ROUTINE const Scheduler_Control_Scheduler_Get_by_CPU (const Per_CPU_Control *cpu)
 
RTEMS_INLINE_ROUTINE Scheduler_Node_Scheduler_Thread_get_own_node (const Thread_Control *the_thread)
 
RTEMS_INLINE_ROUTINE void _Scheduler_Schedule (Thread_Control *the_thread)
 The preferred method to add a new scheduler is to define the jump table entries and add a case to the _Scheduler_Initialize routine. More...
 
RTEMS_INLINE_ROUTINE void _Scheduler_Yield (Thread_Control *the_thread)
 Scheduler yield with a particular thread. More...
 
RTEMS_INLINE_ROUTINE void _Scheduler_Block (Thread_Control *the_thread)
 Blocks a thread with respect to the scheduler. More...
 
RTEMS_INLINE_ROUTINE void _Scheduler_Unblock (Thread_Control *the_thread)
 Unblocks a thread with respect to the scheduler. More...
 
RTEMS_INLINE_ROUTINE void _Scheduler_Change_priority (Thread_Control *the_thread, Priority_Control new_priority, bool prepend_it)
 Propagates a priority change of a thread to the scheduler. More...
 
RTEMS_INLINE_ROUTINE void _Scheduler_Node_initialize (const Scheduler_Control *scheduler, Thread_Control *the_thread)
 Initializes a scheduler node. More...
 
RTEMS_INLINE_ROUTINE void _Scheduler_Node_destroy (const Scheduler_Control *scheduler, Thread_Control *the_thread)
 Destroys a scheduler node. More...
 
RTEMS_INLINE_ROUTINE void _Scheduler_Update_priority (Thread_Control *the_thread, Priority_Control new_priority)
 Updates the scheduler about a priority change of a not ready thread. More...
 
RTEMS_INLINE_ROUTINE int _Scheduler_Priority_compare (const Scheduler_Control *scheduler, Priority_Control p1, Priority_Control p2)
 Compares two priority values. More...
 
RTEMS_INLINE_ROUTINE void _Scheduler_Release_job (Thread_Control *the_thread, uint32_t length)
 Releases a job of a thread with respect to the scheduler. More...
 
RTEMS_INLINE_ROUTINE void _Scheduler_Tick (void)
 Scheduler method invoked at each clock tick. More...
 
RTEMS_INLINE_ROUTINE void _Scheduler_Start_idle (const Scheduler_Control *scheduler, Thread_Control *the_thread, Per_CPU_Control *cpu)
 Starts the idle thread for a particular processor. More...
 
RTEMS_INLINE_ROUTINE bool _Scheduler_Has_processor_ownership (const Scheduler_Control *scheduler, uint32_t cpu_index)
 
RTEMS_INLINE_ROUTINE void _Scheduler_Set (const Scheduler_Control *scheduler, Thread_Control *the_thread)
 
RTEMS_INLINE_ROUTINE void _Scheduler_Update_heir (Thread_Control *new_heir, bool force_dispatch)
 
RTEMS_INLINE_ROUTINE void _Scheduler_Generic_block (const Scheduler_Control *scheduler, Thread_Control *the_thread, void(*extract)(const Scheduler_Control *, Thread_Control *), void(*schedule)(const Scheduler_Control *, Thread_Control *, bool))
 
RTEMS_INLINE_ROUTINE bool _Scheduler_Is_priority_lower_than (const Scheduler_Control *scheduler, Priority_Control p1, Priority_Control p2)
 Returns true if p1 encodes a lower priority than p2 in the intuitive sense of priority.
 
RTEMS_INLINE_ROUTINE bool _Scheduler_Is_priority_higher_than (const Scheduler_Control *scheduler, Priority_Control p1, Priority_Control p2)
 Returns true if p1 encodes a higher priority than p2 in the intuitive sense of priority.
 
RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_processor_count (const Scheduler_Control *scheduler)
 
RTEMS_INLINE_ROUTINE Objects_Id _Scheduler_Build_id (uint32_t scheduler_index)
 
RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index_by_id (Objects_Id id)
 
RTEMS_INLINE_ROUTINE bool _Scheduler_Get_by_id (Objects_Id id, const Scheduler_Control **scheduler_p)
 
RTEMS_INLINE_ROUTINE bool _Scheduler_Is_id_valid (Objects_Id id)
 
RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index (const Scheduler_Control *scheduler)
 
RTEMS_INLINE_ROUTINE Scheduler_Node_Scheduler_Thread_get_node (const Thread_Control *the_thread)
 
RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize (Scheduler_Node *node, Thread_Control *the_thread)
 
RTEMS_INLINE_ROUTINE void _Scheduler_Acquire (Thread_Control *the_thread, ISR_lock_Context *lock_context)
 Acquires the scheduler instance of the thread. More...
 
RTEMS_INLINE_ROUTINE void _Scheduler_Release (Thread_Control *the_thread, ISR_lock_Context *lock_context)
 Releases the scheduler instance of the thread. More...
 

Variables

const Scheduler_Control _Scheduler_Table []
 Registered schedulers. More...
 

Detailed Description

This handler encapsulates functionality related to managing sets of threads that are ready for execution.

Macro Definition Documentation

◆ _Scheduler_Count

#define _Scheduler_Count   ( (size_t) 1 )

Count of registered schedulers.

Application provided via <rtems/confdefs.h> on SMP configurations.

It is very important that this is a compile-time constant on uni-processor configurations (in this case RTEMS_SMP is not defined) so that the compiler can optimize the some loops away

See also
_Scheduler_Table.

Referenced by _Scheduler_Handler_initialization(), and rtems_scheduler_ident().

Typedef Documentation

◆ Scheduler_Context

Scheduler context.

The scheduler context of a particular scheduler implementation must place this structure at the begin of its context structure.

Function Documentation

◆ _Scheduler_Acquire()

RTEMS_INLINE_ROUTINE void _Scheduler_Acquire ( Thread_Control the_thread,
ISR_lock_Context lock_context 
)

Acquires the scheduler instance of the thread.

Parameters
[in]the_threadThe thread.
[in]lock_contextThe lock context for _Scheduler_Release().

References _ISR_lock_ISR_disable_and_acquire.

◆ _Scheduler_Block()

RTEMS_INLINE_ROUTINE void _Scheduler_Block ( Thread_Control the_thread)

Blocks a thread with respect to the scheduler.

This routine removes the_thread from the scheduling decision for the scheduler. The primary task is to remove the thread from the ready queue. It performs any necessary schedulering operations including the selection of a new heir thread.

Parameters
[in]the_threadThe thread.

◆ _Scheduler_Change_priority()

RTEMS_INLINE_ROUTINE void _Scheduler_Change_priority ( Thread_Control the_thread,
Priority_Control  new_priority,
bool  prepend_it 
)

Propagates a priority change of a thread to the scheduler.

The caller must ensure that the thread is in the ready state. The caller must ensure that the priority value actually changed and is not equal to the current priority value.

The operation must update the heir and thread dispatch necessary variables in case the set of scheduled threads changes.

Parameters
[in]the_threadThe thread changing its priority.
[in]new_priorityThe new thread priority.
[in]prepend_itIn case this is true, then enqueue the thread as the first of its priority group, otherwise enqueue the thread as the last of its priority group.

◆ _Scheduler_default_Node_destroy()

void _Scheduler_default_Node_destroy ( const Scheduler_Control scheduler,
Thread_Control the_thread 
)

Does nothing.

Parameters
[in]schedulerUnused.
[in]the_threadUnused.

◆ _Scheduler_default_Node_initialize()

void _Scheduler_default_Node_initialize ( const Scheduler_Control scheduler,
Thread_Control the_thread 
)

Does nothing.

Parameters
[in]schedulerUnused.
[in]the_threadUnused.

◆ _Scheduler_default_Release_job()

void _Scheduler_default_Release_job ( const Scheduler_Control scheduler,
Thread_Control the_thread,
uint32_t  deadline 
)

Does nothing.

Parameters
[in]schedulerUnused.
[in]the_threadUnused.
[in]deadlineUnused.

◆ _Scheduler_default_Schedule()

void _Scheduler_default_Schedule ( const Scheduler_Control scheduler,
Thread_Control the_thread 
)

Does nothing.

Parameters
[in]schedulerUnused.
[in]the_threadUnused.

◆ _Scheduler_default_Start_idle()

void _Scheduler_default_Start_idle ( const Scheduler_Control scheduler,
Thread_Control the_thread,
struct Per_CPU_Control cpu 
)

Starts an idle thread.

Parameters
[in]schedulerThe scheduler.
[in]the_threadAn idle thread.
[in]cpuThis parameter is unused.

References _Scheduler_Unblock().

◆ _Scheduler_default_Tick()

void _Scheduler_default_Tick ( const Scheduler_Control scheduler,
Thread_Control executing 
)

Performs tick operations depending on the CPU budget algorithm for each executing thread.

This routine is invoked as part of processing each clock tick.

Parameters
[in]schedulerThe scheduler.
[in]executingAn executing thread.

References _States_Is_ready(), Thread_Control::budget_algorithm, Thread_Control::current_state, and Thread_Control::is_preemptible.

◆ _Scheduler_default_Update_priority()

void _Scheduler_default_Update_priority ( const Scheduler_Control scheduler,
Thread_Control the_thread,
Priority_Control  new_priority 
)

Does nothing.

Parameters
[in]schedulerUnused.
[in]the_threadUnused.
[in]new_priorityUnused.

◆ _Scheduler_Handler_initialization()

void _Scheduler_Handler_initialization ( void  )

Initializes the scheduler to the policy chosen by the user.

This routine initializes the scheduler to the policy chosen by the user through confdefs, or to the priority scheduler with ready chains by default.

References _Scheduler_Count, _Scheduler_Table, Scheduler_Operations::initialize, and Scheduler_Control::Operations.

◆ _Scheduler_Node_destroy()

RTEMS_INLINE_ROUTINE void _Scheduler_Node_destroy ( const Scheduler_Control scheduler,
Thread_Control the_thread 
)

Destroys a scheduler node.

The caller must ensure that _Scheduler_Node_destroy() will be called only after a corresponding _Scheduler_Node_initialize().

Parameters
[in]schedulerThe scheduler instance.
[in]the_threadThe thread containing the scheduler node.

References Scheduler_Operations::node_destroy, and Scheduler_Control::Operations.

◆ _Scheduler_Node_initialize()

RTEMS_INLINE_ROUTINE void _Scheduler_Node_initialize ( const Scheduler_Control scheduler,
Thread_Control the_thread 
)

Initializes a scheduler node.

The scheduler node contains arbitrary data on function entry. The caller must ensure that _Scheduler_Node_destroy() will be called after a _Scheduler_Node_initialize() before the memory of the scheduler node is destroyed.

Parameters
[in]schedulerThe scheduler instance.
[in]the_threadThe thread containing the scheduler node.

References Scheduler_Operations::node_initialize, and Scheduler_Control::Operations.

◆ _Scheduler_Priority_compare()

RTEMS_INLINE_ROUTINE int _Scheduler_Priority_compare ( const Scheduler_Control scheduler,
Priority_Control  p1,
Priority_Control  p2 
)

Compares two priority values.

Parameters
[in]schedulerThe scheduler instance.
[in]p1The first priority value.
[in]p2The second priority value.
Return values
negativeThe value p1 encodes a lower priority than p2 in the intuitive sense of priority.
0The priorities p1 and p2 are equal.
positiveThe value p1 encodes a higher priority than p2 in the intuitive sense of priority.
See also
_Scheduler_Is_priority_lower_than() and _Scheduler_Is_priority_higher_than().

References Scheduler_Control::Operations, and Scheduler_Operations::priority_compare.

Referenced by _Scheduler_Is_priority_higher_than(), and _Scheduler_Is_priority_lower_than().

◆ _Scheduler_Release()

RTEMS_INLINE_ROUTINE void _Scheduler_Release ( Thread_Control the_thread,
ISR_lock_Context lock_context 
)

Releases the scheduler instance of the thread.

Parameters
[in]the_threadThe thread.
[in]lock_contextThe lock context used for _Scheduler_Acquire().

References _ISR_lock_Release_and_ISR_enable.

◆ _Scheduler_Release_job()

RTEMS_INLINE_ROUTINE void _Scheduler_Release_job ( Thread_Control the_thread,
uint32_t  length 
)

Releases a job of a thread with respect to the scheduler.

Parameters
[in]the_threadThe thread.
[in]lengthThe period length.

◆ _Scheduler_Schedule()

RTEMS_INLINE_ROUTINE void _Scheduler_Schedule ( Thread_Control the_thread)

The preferred method to add a new scheduler is to define the jump table entries and add a case to the _Scheduler_Initialize routine.

Generic scheduling implementations that rely on the ready queue only can be found in the _Scheduler_queue_XXX functions. General scheduling decision.

This kernel routine implements the scheduling decision logic for the scheduler. It does NOT dispatch.

Parameters
[in]the_threadThe thread which state changed previously.

◆ _Scheduler_Start_idle()

RTEMS_INLINE_ROUTINE void _Scheduler_Start_idle ( const Scheduler_Control scheduler,
Thread_Control the_thread,
Per_CPU_Control cpu 
)

Starts the idle thread for a particular processor.

Parameters
[in]schedulerThe scheduler instance.
[in,out]the_threadThe idle thread for the processor.
[in,out]cpuThe processor for the idle thread.
See also
_Thread_Create_idle().

References Scheduler_Control::Operations, RTEMS_INLINE_ROUTINE, and Scheduler_Operations::start_idle.

◆ _Scheduler_Tick()

RTEMS_INLINE_ROUTINE void _Scheduler_Tick ( void  )

Scheduler method invoked at each clock tick.

This method is invoked at each clock tick to allow the scheduler implementation to perform any activities required. For the scheduler which support standard RTEMS features, this includes time-slicing management.

Referenced by _Watchdog_Tick().

◆ _Scheduler_Unblock()

RTEMS_INLINE_ROUTINE void _Scheduler_Unblock ( Thread_Control the_thread)

Unblocks a thread with respect to the scheduler.

This routine adds the_thread to the scheduling decision for the scheduler. The primary task is to add the thread to the ready queue per the schedulering policy and update any appropriate scheduling variables, for example the heir thread.

Parameters
[in]the_threadThe thread.

Referenced by _Scheduler_default_Start_idle().

◆ _Scheduler_Update_priority()

RTEMS_INLINE_ROUTINE void _Scheduler_Update_priority ( Thread_Control the_thread,
Priority_Control  new_priority 
)

Updates the scheduler about a priority change of a not ready thread.

Parameters
[in]the_threadThe thread.
[in]new_priorityThe new priority of the thread.

◆ _Scheduler_Yield()

RTEMS_INLINE_ROUTINE void _Scheduler_Yield ( Thread_Control the_thread)

Scheduler yield with a particular thread.

This routine is invoked when a thread wishes to voluntarily transfer control of the processor to another thread.

Parameters
[in]the_threadThe yielding thread.

Variable Documentation

◆ _Scheduler_Table

const Scheduler_Control _Scheduler_Table[]

Registered schedulers.

Application provided via <rtems/confdefs.h>.

See also
_Scheduler_Count.

Referenced by _Scheduler_Handler_initialization(), and rtems_scheduler_ident().