RTEMS
5.0.0
|
Modules | |
CBS Scheduler | |
Deterministic Priority Scheduler | |
EDF Scheduler | |
SMP Scheduler | |
Simple Priority Scheduler | |
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 | 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 | 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 | scheduleredfreleasejob.c |
Scheduler EDF Release Job. | |
file | scheduleredfschedule.c |
Scheduler EDF Allocate. | |
file | scheduleredfunblock.c |
Scheduler EDF Unblock. | |
file | scheduleredfyield.c |
Scheduler EDF Yield. | |
file | schedulerpriorityblock.c |
Scheduler Priority Block. | |
file | schedulerprioritychangepriority.c |
Removes Thread from Thread Queue. | |
file | schedulerpriorityschedule.c |
Priority Scheduler Schedule Method. | |
file | schedulerpriorityunblock.c |
Scheduler Priority Unblock. | |
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. | |
Data Structures | |
struct | Scheduler_Operations |
The scheduler operations. More... | |
struct | Scheduler_Context |
Scheduler context. More... | |
struct | _Scheduler_Control |
Scheduler control. More... | |
Macros | |
#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 |
#define | PRIORITY_MAXIMUM ( _Scheduler_Table[ 0 ].maximum_priority ) |
This defines the lowest (least important) thread priority of the first scheduler instance. | |
#define | SCHEDULER_PRIORITY_MAP(priority) ( ( priority ) << 1 ) |
Maps a priority value to support the append indicator. | |
#define | SCHEDULER_PRIORITY_UNMAP(priority) ( ( priority ) >> 1 ) |
Returns the plain priority value. | |
#define | SCHEDULER_PRIORITY_PURIFY(priority) ( ( priority ) & ~( (Priority_Control) SCHEDULER_PRIORITY_APPEND_FLAG ) ) |
Clears the priority append indicator bit. | |
#define | SCHEDULER_PRIORITY_APPEND(priority) ( ( priority ) | SCHEDULER_PRIORITY_APPEND_FLAG ) |
Returns the priority control with the append indicator bit set. | |
#define | SCHEDULER_PRIORITY_IS_APPEND(priority) ( ( ( priority ) & SCHEDULER_PRIORITY_APPEND_FLAG ) != 0 ) |
Returns true, if the item should be appended to its priority group, otherwise returns false and the item should be prepended to its priority group. | |
Typedefs | |
typedef struct _Scheduler_Control | Scheduler_Control |
typedef struct Scheduler_Context | Scheduler_Context |
Scheduler context. More... | |
Functions | |
Priority_Control | _Scheduler_default_Map_priority (const Scheduler_Control *scheduler, Priority_Control priority) |
Returns the scheduler internal thread priority mapped by SCHEDULER_PRIORITY_MAP(). More... | |
Priority_Control | _Scheduler_default_Unmap_priority (const Scheduler_Control *scheduler, Priority_Control priority) |
Returns the user visible thread priority unmapped by SCHEDULER_PRIORITY_UNMAP(). More... | |
void | _Scheduler_default_Schedule (const Scheduler_Control *scheduler, Thread_Control *the_thread) |
Does nothing. More... | |
void | _Scheduler_default_Node_initialize (const Scheduler_Control *scheduler, Scheduler_Node *node, Thread_Control *the_thread, Priority_Control priority) |
Performs the scheduler base node initialization. More... | |
void | _Scheduler_default_Node_destroy (const Scheduler_Control *scheduler, Scheduler_Node *node) |
Does nothing. More... | |
void | _Scheduler_default_Release_job (const Scheduler_Control *scheduler, Thread_Control *the_thread, Priority_Node *priority_node, uint64_t deadline, Thread_queue_Context *queue_context) |
Does nothing. More... | |
void | _Scheduler_default_Cancel_job (const Scheduler_Control *scheduler, Thread_Control *the_thread, Priority_Node *priority_node, Thread_queue_Context *queue_context) |
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_by_CPU (const Per_CPU_Control *cpu) |
RTEMS_INLINE_ROUTINE void | _Scheduler_Acquire_critical (const Scheduler_Control *scheduler, ISR_lock_Context *lock_context) |
Acquires the scheduler instance inside a critical section (interrupts disabled). More... | |
RTEMS_INLINE_ROUTINE void | _Scheduler_Release_critical (const Scheduler_Control *scheduler, ISR_lock_Context *lock_context) |
Releases the scheduler instance inside a critical section (interrupts disabled). More... | |
RTEMS_INLINE_ROUTINE void | _Scheduler_Schedule (Thread_Control *the_thread) |
General scheduling decision. 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_Update_priority (Thread_Control *the_thread) |
Propagates a priority change of a thread to the scheduler. More... | |
RTEMS_INLINE_ROUTINE Priority_Control | _Scheduler_Map_priority (const Scheduler_Control *scheduler, Priority_Control priority) |
Maps a thread priority from the user domain to the scheduler domain. More... | |
RTEMS_INLINE_ROUTINE Priority_Control | _Scheduler_Unmap_priority (const Scheduler_Control *scheduler, Priority_Control priority) |
Unmaps a thread priority from the scheduler domain to the user domain. More... | |
RTEMS_INLINE_ROUTINE void | _Scheduler_Node_initialize (const Scheduler_Control *scheduler, Scheduler_Node *node, Thread_Control *the_thread, Priority_Control priority) |
Initializes a scheduler node. More... | |
RTEMS_INLINE_ROUTINE void | _Scheduler_Node_destroy (const Scheduler_Control *scheduler, Scheduler_Node *node) |
Destroys a scheduler node. More... | |
RTEMS_INLINE_ROUTINE void | _Scheduler_Release_job (Thread_Control *the_thread, Priority_Node *priority_node, uint64_t deadline, Thread_queue_Context *queue_context) |
Releases a job of a thread with respect to the scheduler. More... | |
RTEMS_INLINE_ROUTINE void | _Scheduler_Cancel_job (Thread_Control *the_thread, Priority_Node *priority_node, Thread_queue_Context *queue_context) |
Cancels a job of a thread with respect to the scheduler. More... | |
RTEMS_INLINE_ROUTINE void | _Scheduler_Tick (const Per_CPU_Control *cpu) |
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 const Processor_mask * | _Scheduler_Get_processors (const Scheduler_Control *scheduler) |
bool | _Scheduler_Get_affinity (Thread_Control *the_thread, size_t cpusetsize, cpu_set_t *cpuset) |
RTEMS_INLINE_ROUTINE bool | _Scheduler_default_Set_affinity_body (const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node, const Processor_mask *affinity) |
bool | _Scheduler_Set_affinity (Thread_Control *the_thread, size_t cpusetsize, const cpu_set_t *cpuset) |
RTEMS_INLINE_ROUTINE void | _Scheduler_Generic_block (const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node, void(*extract)(const Scheduler_Control *, Thread_Control *, Scheduler_Node *), void(*schedule)(const Scheduler_Control *, Thread_Control *, bool)) |
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 const Scheduler_Control * | _Scheduler_Get_by_id (Objects_Id id) |
RTEMS_INLINE_ROUTINE uint32_t | _Scheduler_Get_index (const Scheduler_Control *scheduler) |
RTEMS_INLINE_ROUTINE void | _Scheduler_Update_heir (Thread_Control *new_heir, bool force_dispatch) |
RTEMS_INLINE_ROUTINE Status_Control | _Scheduler_Set (const Scheduler_Control *new_scheduler, Thread_Control *the_thread, Priority_Control priority) |
Variables | |
const Scheduler_Control | _Scheduler_Table [] |
Registered schedulers. More... | |
This handler encapsulates functionality related to managing sets of threads that are ready for execution.
#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
typedef struct Scheduler_Context Scheduler_Context |
Scheduler context.
The scheduler context of a particular scheduler implementation must place this structure at the begin of its context structure.
RTEMS_INLINE_ROUTINE void _Scheduler_Acquire_critical | ( | const Scheduler_Control * | scheduler, |
ISR_lock_Context * | lock_context | ||
) |
Acquires the scheduler instance inside a critical section (interrupts disabled).
[in] | scheduler | The scheduler instance. |
[in] | lock_context | The lock context to use for _Scheduler_Release_critical(). |
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.
[in] | the_thread | The thread. |
RTEMS_INLINE_ROUTINE void _Scheduler_Cancel_job | ( | Thread_Control * | the_thread, |
Priority_Node * | priority_node, | ||
Thread_queue_Context * | queue_context | ||
) |
Cancels a job of a thread with respect to the scheduler.
[in] | the_thread | The thread. |
[in] | priority_node | The priority node of the job. |
[in] | queue_context | The thread queue context to provide the set of threads for _Thread_Priority_update(). |
void _Scheduler_default_Cancel_job | ( | const Scheduler_Control * | scheduler, |
Thread_Control * | the_thread, | ||
Priority_Node * | priority_node, | ||
Thread_queue_Context * | queue_context | ||
) |
Does nothing.
[in] | scheduler | Unused. |
[in] | the_thread | Unused. |
[in] | priority_node | Unused. |
[in] | queue_context | Unused. |
NULL | Always. |
Priority_Control _Scheduler_default_Map_priority | ( | const Scheduler_Control * | scheduler, |
Priority_Control | priority | ||
) |
Returns the scheduler internal thread priority mapped by SCHEDULER_PRIORITY_MAP().
[in] | scheduler | Unused. |
[in] | priority | The user visible thread priority. |
void _Scheduler_default_Node_destroy | ( | const Scheduler_Control * | scheduler, |
Scheduler_Node * | node | ||
) |
Does nothing.
[in] | scheduler | Unused. |
[in] | node | Unused. |
void _Scheduler_default_Node_initialize | ( | const Scheduler_Control * | scheduler, |
Scheduler_Node * | node, | ||
Thread_Control * | the_thread, | ||
Priority_Control | priority | ||
) |
Performs the scheduler base node initialization.
[in] | scheduler | Unused. |
[in] | node | The node to initialize. |
[in] | the_thread | Unused. |
[in] | priority | The thread priority. |
void _Scheduler_default_Release_job | ( | const Scheduler_Control * | scheduler, |
Thread_Control * | the_thread, | ||
Priority_Node * | priority_node, | ||
uint64_t | deadline, | ||
Thread_queue_Context * | queue_context | ||
) |
Does nothing.
[in] | scheduler | Unused. |
[in] | the_thread | Unused. |
[in] | priority_node | Unused. |
[in] | deadline | Unused. |
[in] | queue_context | Unused. |
NULL | Always. |
void _Scheduler_default_Schedule | ( | const Scheduler_Control * | scheduler, |
Thread_Control * | the_thread | ||
) |
Does nothing.
[in] | scheduler | Unused. |
[in] | the_thread | Unused. |
void _Scheduler_default_Start_idle | ( | const Scheduler_Control * | scheduler, |
Thread_Control * | the_thread, | ||
struct Per_CPU_Control * | cpu | ||
) |
Starts an idle thread.
[in] | scheduler | The scheduler. |
[in] | the_thread | An idle thread. |
[in] | cpu | This parameter is unused. |
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.
[in] | scheduler | The scheduler. |
[in] | executing | An executing thread. |
Priority_Control _Scheduler_default_Unmap_priority | ( | const Scheduler_Control * | scheduler, |
Priority_Control | priority | ||
) |
Returns the user visible thread priority unmapped by SCHEDULER_PRIORITY_UNMAP().
[in] | scheduler | Unused. |
[in] | priority | The scheduler internal thread priority. |
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.
RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Map_priority | ( | const Scheduler_Control * | scheduler, |
Priority_Control | priority | ||
) |
Maps a thread priority from the user domain to the scheduler domain.
Let M be the maximum scheduler priority. The mapping must be bijective in the closed interval [0, M], e.g. _Scheduler_Unmap_priority( scheduler, _Scheduler_Map_priority( scheduler, p ) ) == p for all p in [0, M]. For other values the mapping is undefined.
[in] | scheduler | The scheduler instance. |
[in] | priority | The user domain thread priority. |
RTEMS_INLINE_ROUTINE void _Scheduler_Node_destroy | ( | const Scheduler_Control * | scheduler, |
Scheduler_Node * | node | ||
) |
Destroys a scheduler node.
The caller must ensure that _Scheduler_Node_destroy() will be called only after a corresponding _Scheduler_Node_initialize().
[in] | scheduler | The scheduler instance. |
[in] | node | The scheduler node to destroy. |
RTEMS_INLINE_ROUTINE void _Scheduler_Node_initialize | ( | const Scheduler_Control * | scheduler, |
Scheduler_Node * | node, | ||
Thread_Control * | the_thread, | ||
Priority_Control | priority | ||
) |
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.
[in] | scheduler | The scheduler instance. |
[in] | node | The scheduler node to initialize. |
[in] | the_thread | The thread of the scheduler node to initialize. |
[in] | priority | The thread priority. |
RTEMS_INLINE_ROUTINE void _Scheduler_Release_critical | ( | const Scheduler_Control * | scheduler, |
ISR_lock_Context * | lock_context | ||
) |
Releases the scheduler instance inside a critical section (interrupts disabled).
[in] | scheduler | The scheduler instance. |
[in] | lock_context | The lock context used for _Scheduler_Acquire_critical(). |
RTEMS_INLINE_ROUTINE void _Scheduler_Release_job | ( | Thread_Control * | the_thread, |
Priority_Node * | priority_node, | ||
uint64_t | deadline, | ||
Thread_queue_Context * | queue_context | ||
) |
Releases a job of a thread with respect to the scheduler.
[in] | the_thread | The thread. |
[in] | priority_node | The priority node of the job. |
[in] | deadline | The deadline in watchdog ticks since boot. |
[in] | queue_context | The thread queue context to provide the set of threads for _Thread_Priority_update(). |
RTEMS_INLINE_ROUTINE void _Scheduler_Schedule | ( | Thread_Control * | the_thread | ) |
General scheduling decision.
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. This kernel routine implements the scheduling decision logic for the scheduler. It does NOT dispatch.
[in] | the_thread | The thread which state changed previously. |
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.
[in] | scheduler | The scheduler instance. |
[in,out] | the_thread | The idle thread for the processor. |
[in,out] | cpu | The processor for the idle thread. |
RTEMS_INLINE_ROUTINE void _Scheduler_Tick | ( | const Per_CPU_Control * | cpu | ) |
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.
RTEMS_INLINE_ROUTINE void _Scheduler_Unblock | ( | Thread_Control * | the_thread | ) |
Unblocks a thread with respect to the scheduler.
This operation must fetch the latest thread priority value for this scheduler instance and update its internal state if necessary.
[in] | the_thread | The thread. |
RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Unmap_priority | ( | const Scheduler_Control * | scheduler, |
Priority_Control | priority | ||
) |
Unmaps a thread priority from the scheduler domain to the user domain.
[in] | scheduler | The scheduler instance. |
[in] | priority | The scheduler domain thread priority. |
RTEMS_INLINE_ROUTINE void _Scheduler_Update_priority | ( | Thread_Control * | the_thread | ) |
Propagates a priority change of a thread to the scheduler.
On uni-processor configurations, this operation must evaluate the thread state. In case the thread is not ready, then the priority update should be deferred to the next scheduler unblock operation.
The operation must update the heir and thread dispatch necessary variables in case the set of scheduled threads changes.
[in] | the_thread | The thread changing its priority. |
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.
[in] | the_thread | The yielding thread. |
const Scheduler_Control _Scheduler_Table[] |