RTEMS: Scheduler Handler

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
Modules | Files | Data Structures | Macros | Typedefs | Functions | Variables
Scheduler Handler
Internal » SuperCore

## Modules
| CBS Scheduler
| CBS Scheduler.
| Deterministic Priority Scheduler
| Deterministic Priority Scheduler.
| EDF Scheduler
| EDF Scheduler.
| SMP Scheduler
| SMP Scheduler.
| Simple Priority Scheduler
| Simple Priority Scheduler.

## Files
file | scheduler.h
| Constants and Structures Associated with the Scheduler.
file | schedulerimpl.h
| Inlined Routines Associated with the Manipulation of the Scheduler.
file | schedulernode.h
| Handles Scheduler Nodes.
file | schedulernodeimpl.h
| Scheduler Node Implementation.
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...
struct | Scheduler_Node
| Scheduler node for per-thread data. More...

## Macros
#define | _Scheduler_Count ( (size_t) 1 )
| Count of registered schedulers.
#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_NODE_OF_WAIT_PRIORITY_NODE(node) RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Priority.Node.Node.Chain )
#define | SCHEDULER_NODE_OF_WAIT_PRIORITY(node) RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Priority )
#define | SCHEDULER_PRIORITY_APPEND_FLAG 1
| Priority append indicator for the priority control used for the scheduler node priority.
#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.
typedef struct Scheduler_Node | Scheduler_Node

## 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().
Priority_Control | _Scheduler_default_Unmap_priority (const Scheduler_Control *scheduler, Priority_Control priority)
| Returns the user visible thread priority unmapped by SCHEDULER_PRIORITY_UNMAP().
void | _Scheduler_default_Schedule (const Scheduler_Control *scheduler, Thread_Control *the_thread)
| Does nothing.
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.
void | _Scheduler_default_Node_destroy (const Scheduler_Control *scheduler, Scheduler_Node *node)
| Does nothing.
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.
void | _Scheduler_default_Cancel_job (const Scheduler_Control *scheduler, Thread_Control *the_thread, Priority_Node *priority_node, Thread_queue_Context *queue_context)
| Does nothing.
void | _Scheduler_default_Tick (const Scheduler_Control *scheduler, Thread_Control *executing)
| Performs tick operations depending on the CPU budget algorithm for each executing thread.
void | _Scheduler_default_Start_idle (const Scheduler_Control *scheduler, Thread_Control *the_thread, struct Per_CPU_Control *cpu)
| Starts an idle thread.
void | _Scheduler_Handler_initialization (void)
| Initializes the scheduler to the policy chosen by the user.
RTEMS_INLINE_ROUTINE Scheduler_Context * | _Scheduler_Get_context (const Scheduler_Control *scheduler)
| Gets the context of the scheduler.
RTEMS_INLINE_ROUTINE const Scheduler_Control * | _Scheduler_Get_by_CPU (const Per_CPU_Control *cpu)
| Gets the scheduler for the 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).
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).
RTEMS_INLINE_ROUTINE void | _Scheduler_Schedule (Thread_Control *the_thread)
| General scheduling decision.
RTEMS_INLINE_ROUTINE void | _Scheduler_Yield (Thread_Control *the_thread)
| Scheduler yield with a particular thread.
RTEMS_INLINE_ROUTINE void | _Scheduler_Block (Thread_Control *the_thread)
| Blocks a thread with respect to the scheduler.
RTEMS_INLINE_ROUTINE void | _Scheduler_Unblock (Thread_Control *the_thread)
| Unblocks a thread with respect to the scheduler.
RTEMS_INLINE_ROUTINE void | _Scheduler_Update_priority (Thread_Control *the_thread)
| Propagates a priority change of a thread to the scheduler.
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.
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.
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.
RTEMS_INLINE_ROUTINE void | _Scheduler_Node_destroy (const Scheduler_Control *scheduler, Scheduler_Node *node)
| Destroys a scheduler node.
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.
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.
RTEMS_INLINE_ROUTINE void | _Scheduler_Tick (const Per_CPU_Control *cpu)
| Scheduler method invoked at each clock tick.
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.
RTEMS_INLINE_ROUTINE bool | _Scheduler_Has_processor_ownership (const Scheduler_Control *scheduler, uint32_t cpu_index)
| Checks if the scheduler of the cpu with the given index is equal to the given scheduler.
RTEMS_INLINE_ROUTINE const Processor_mask * | _Scheduler_Get_processors (const Scheduler_Control *scheduler)
| Gets the processors of the scheduler.
bool | _Scheduler_Get_affinity (Thread_Control *the_thread, size_t cpusetsize, cpu_set_t *cpuset)
| Copies the thread's scheduler's affinity to the given 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)
| Checks if the affinity is a subset of the online processors.
bool | _Scheduler_Set_affinity (Thread_Control *the_thread, size_t cpusetsize, const cpu_set_t *cpuset)
| Sets the thread's scheduler's affinity.
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))
| Blocks the thread.
RTEMS_INLINE_ROUTINE uint32_t | _Scheduler_Get_processor_count (const Scheduler_Control *scheduler)
| Gets the number of processors of the scheduler.
RTEMS_INLINE_ROUTINE Objects_Id | _Scheduler_Build_id (uint32_t scheduler_index)
| Builds an object build id.
RTEMS_INLINE_ROUTINE uint32_t | _Scheduler_Get_index_by_id (Objects_Id id)
| Gets the scheduler index from the given object build id.
RTEMS_INLINE_ROUTINE const Scheduler_Control * | _Scheduler_Get_by_id (Objects_Id id)
| Gets the scheduler from the given object build id.
RTEMS_INLINE_ROUTINE uint32_t | _Scheduler_Get_index (const Scheduler_Control *scheduler)
| Gets the index of the scheduler.
RTEMS_INLINE_ROUTINE void | _Scheduler_Update_heir (Thread_Control *new_heir, bool force_dispatch)
| Updates the heir.
RTEMS_INLINE_ROUTINE Status_Control | _Scheduler_Set (const Scheduler_Control *new_scheduler, Thread_Control *the_thread, Priority_Control priority)
| Sets a new scheduler.
RTEMS_INLINE_ROUTINE void | _Scheduler_Node_do_initialize (const struct _Scheduler_Control *scheduler, Scheduler_Node *node, Thread_Control *the_thread, Priority_Control priority)
| Initializes a node.
RTEMS_INLINE_ROUTINE const Scheduler_Control * | _Scheduler_Node_get_scheduler (const Scheduler_Node *node)
| Gets the scheduler of the node.
RTEMS_INLINE_ROUTINE Thread_Control * | _Scheduler_Node_get_owner (const Scheduler_Node *node)
| Gets the owner of the node.
RTEMS_INLINE_ROUTINE Priority_Control | _Scheduler_Node_get_priority (Scheduler_Node *node)
| Gets the priority of the node.
RTEMS_INLINE_ROUTINE void | _Scheduler_Node_set_priority (Scheduler_Node *node, Priority_Control new_priority, bool prepend_it)
| Sets the priority of the node.

## Variables
const Scheduler_Control | _Scheduler_Table []
| Registered schedulers.

## 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.

## Typedef Documentation

## ◆ Scheduler_Context

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.

## Function Documentation

## ◆ _Scheduler_Acquire_critical()

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).

Parameters

  scheduler | The scheduler instance.
  lock_context | The lock context to use for _Scheduler_Release_critical().

## ◆ _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 scheduling operations including the selection of a new heir thread.

Parameters

  the_thread | The thread.

## ◆ _Scheduler_Build_id()

RTEMS_INLINE_ROUTINE Objects_Id _Scheduler_Build_id | ( | uint32_t | scheduler_index | ) |

Builds an object build id.

Parameters

  scheduler_index | The index to build the build id out of.

Returns
  The build id.

## ◆ _Scheduler_Cancel_job()

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.

Parameters

  the_thread | The thread.
  priority_node | The priority node of the job.
  queue_context | The thread queue context to provide the set of threads for _Thread_Priority_update().

## ◆ _Scheduler_default_Cancel_job()

void _Scheduler_default_Cancel_job | ( | const Scheduler_Control * | scheduler,
|  | Thread_Control * | the_thread,
|  | Priority_Node * | priority_node,
|  | Thread_queue_Context * | queue_context
| ) |  |

Does nothing.

Parameters

  scheduler | This parameter is unused.
  the_thread | This parameter is unused.
  priority_node | This parameter is unused.
  queue_context | This parameter is unused.

Returns
  Always returns NULL.

## ◆ _Scheduler_default_Map_priority()

Priority_Control _Scheduler_default_Map_priority | ( | const Scheduler_Control * | scheduler,
|  | Priority_Control | priority
| ) |  |

Returns the scheduler internal thread priority mapped by SCHEDULER_PRIORITY_MAP().

Parameters

  scheduler | Unused.
  priority | The user visible thread priority.

Returns
  The scheduler internal thread priority.

## ◆ _Scheduler_default_Node_destroy()

void _Scheduler_default_Node_destroy | ( | const Scheduler_Control * | scheduler,
|  | Scheduler_Node * | node
| ) |  |

Does nothing.

Parameters

  scheduler | This parameter is unused.
  node | This parameter is unused.

## ◆ _Scheduler_default_Node_initialize()

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.

Parameters

  | scheduler | This parameter is unused.
  [out] | node | The node to initialize.
  | the_thread | This parameter is unused.
  | priority | The thread priority.

## ◆ _Scheduler_default_Release_job()

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.

Parameters

  scheduler | This parameter is unused.
  the_thread | This parameter is unused.
  priority_node | This parameter is unused.
  deadline | This parameter is unused.
  queue_context | This parameter is unused.

Returns
  Always returns NULL.

## ◆ _Scheduler_default_Schedule()

void _Scheduler_default_Schedule | ( | const Scheduler_Control * | scheduler,
|  | Thread_Control * | the_thread
| ) |  |

Does nothing.

Parameters

  scheduler | This parameter is unused.
  the_thread | This parameter is unused.

## ◆ _Scheduler_default_Set_affinity_body()

RTEMS_INLINE_ROUTINE bool _Scheduler_default_Set_affinity_body | ( | const Scheduler_Control * | scheduler,
|  | Thread_Control * | the_thread,
|  | Scheduler_Node * | node,
|  | const Processor_mask * | affinity
| ) |  |

Checks if the affinity is a subset of the online processors.

Parameters

  scheduler | This parameter is unused.
  the_thread | This parameter is unused.
  node | This parameter is unused.
  affinity | The processor mask to check.

Return values

  true | affinity is a subset of the online processors.
  false | affinity is not a subset of the online processors.

## ◆ _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

  | scheduler | This parameter is unused.
  [in,out] | the_thread | An idle thread.
  | cpu | This parameter is unused.

## ◆ _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

  | scheduler | The scheduler.
  [in,out] | executing | An executing thread.

## ◆ _Scheduler_default_Unmap_priority()

Priority_Control _Scheduler_default_Unmap_priority | ( | const Scheduler_Control * | scheduler,
|  | Priority_Control | priority
| ) |  |

Returns the user visible thread priority unmapped by SCHEDULER_PRIORITY_UNMAP().

Parameters

  scheduler | Unused.
  priority | The scheduler internal thread priority.

Returns
  priority The user visible thread priority.

## ◆ _Scheduler_Generic_block()

RTEMS_INLINE_ROUTINE void _Scheduler_Generic_block | ( | const Scheduler_Control * | scheduler,
|  | Thread_Control * | the_thread,
|  | Scheduler_Node * | node,
|  | void(*)(const Scheduler_Control *, Thread_Control *, Scheduler_Node *) | extract,
|  | void(*)(const Scheduler_Control *, Thread_Control *, bool) | schedule
| ) |  |

Blocks the thread.

Parameters

  scheduler | The scheduler instance.
  the_thread | The thread to block.
  node | The corresponding scheduler node.
  extract | Method to extract the thread.
  schedule | Method for scheduling threads.

## ◆ _Scheduler_Get_affinity()

bool _Scheduler_Get_affinity | ( | Thread_Control * | the_thread,
|  | size_t | cpusetsize,
|  | cpu_set_t * | cpuset
| ) |  |

Copies the thread's scheduler's affinity to the given cpuset.

Parameters

  | the_thread | The thread to get the affinity of its scheduler.
  | cpusetsize | The size of cpuset.
  [out] | cpuset | The cpuset that serves as destination for the copy operation

Return values

  true | The copy operation was lossless.
  false | The copy operation was not lossless

## ◆ _Scheduler_Get_by_CPU()

RTEMS_INLINE_ROUTINE const Scheduler_Control * _Scheduler_Get_by_CPU | ( | const Per_CPU_Control * | cpu | ) |

Gets the scheduler for the cpu.

Parameters

  cpu | The cpu control to get the scheduler of.

Returns
  The scheduler for the cpu.

## ◆ _Scheduler_Get_by_id()

RTEMS_INLINE_ROUTINE const Scheduler_Control * _Scheduler_Get_by_id | ( | Objects_Id | id | ) |

Gets the scheduler from the given object build id.

Parameters

  id | The object build id.

Returns
  The scheduler to the object id.

## ◆ _Scheduler_Get_context()

RTEMS_INLINE_ROUTINE Scheduler_Context * _Scheduler_Get_context | ( | const Scheduler_Control * | scheduler | ) |

Gets the context of the scheduler.

Parameters

  scheduler | The scheduler to get the context of.

Returns
  The context of scheduler.

## ◆ _Scheduler_Get_index()

RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index | ( | const Scheduler_Control * | scheduler | ) |

Gets the index of the scheduler.

Parameters

  scheduler | The scheduler to get the index of.

Returns
  The index of the given scheduler.

## ◆ _Scheduler_Get_index_by_id()

RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index_by_id | ( | Objects_Id | id | ) |

Gets the scheduler index from the given object build id.

Parameters

  id | The object build id.

Returns
  The scheduler index.

## ◆ _Scheduler_Get_processor_count()

RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_processor_count | ( | const Scheduler_Control * | scheduler | ) |

Gets the number of processors of the scheduler.

Parameters

  scheduler | The scheduler instance to get the number of processors of.

Returns
  The number of processors.

## ◆ _Scheduler_Get_processors()

RTEMS_INLINE_ROUTINE const Processor_mask * _Scheduler_Get_processors | ( | const Scheduler_Control * | scheduler | ) |

Gets the processors of the scheduler.

Parameters

  scheduler | The scheduler to get the processors of.

Returns
  The processors of the context of the given scheduler.

## ◆ _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.

## ◆ _Scheduler_Has_processor_ownership()

RTEMS_INLINE_ROUTINE bool _Scheduler_Has_processor_ownership | ( | const Scheduler_Control * | scheduler,
|  | uint32_t | cpu_index
| ) |  |

Checks if the scheduler of the cpu with the given index is equal to the given scheduler.

Parameters

  scheduler | The scheduler for the comparison.
  cpu_index | The index of the cpu for the comparison.

Return values

  true | The scheduler of the cpu is the given scheduler.
  false | The scheduler of the cpu is not the given scheduler.

## ◆ _Scheduler_Map_priority()

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.

Parameters

  scheduler | The scheduler instance.
  priority | The user domain thread priority.

Returns
  The corresponding thread priority of the scheduler domain is returned.

## ◆ _Scheduler_Node_destroy()

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().

Parameters

  | scheduler | The scheduler instance.
  [out] | node | The scheduler node to destroy.

## ◆ _Scheduler_Node_do_initialize()

RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize | ( | const struct _Scheduler_Control * | scheduler,
|  | Scheduler_Node * | node,
|  | Thread_Control * | the_thread,
|  | Priority_Control | priority
| ) |  |

Initializes a node.

Parameters

  | scheduler | The scheduler for the initialization of node.
  [out] | node | The node to initialize.
  | the_thread | The thread for the initialization of node.
  | priority | The priority value for node.

## ◆ _Scheduler_Node_get_owner()

RTEMS_INLINE_ROUTINE Thread_Control * _Scheduler_Node_get_owner | ( | const Scheduler_Node * | node | ) |

Gets the owner of the node.

Parameters

  node | The node to get the owner of.

Returns
  The owner of the node.

## ◆ _Scheduler_Node_get_priority()

RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Node_get_priority | ( | Scheduler_Node * | node | ) |

Gets the priority of the node.

Parameters

  node | The node to get the priority of.

Returns
  The priority of the node.

## ◆ _Scheduler_Node_get_scheduler()

RTEMS_INLINE_ROUTINE const Scheduler_Control * _Scheduler_Node_get_scheduler | ( | const Scheduler_Node * | node | ) |

Gets the scheduler of the node.

Parameters

  node | The node to get the scheduler of.

Returns
  The scheduler of the node.

## ◆ _Scheduler_Node_initialize()

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.

Parameters

  | scheduler | The scheduler instance.
  [out] | node | The scheduler node to initialize.
  | the_thread | The thread of the scheduler node to initialize.
  | priority | The thread priority.

## ◆ _Scheduler_Node_set_priority()

RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_priority | ( | Scheduler_Node * | node,
|  | Priority_Control | new_priority,
|  | bool | prepend_it
| ) |  |

Sets the priority of the node.

Parameters

  [in,out] | node | The node to set the priority of.
  | new_priority | The new priority for node.
  | prepend_it | Indicates whether the new priority should be prepended.

## ◆ _Scheduler_Release_critical()

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).

Parameters

  scheduler | The scheduler instance.
  lock_context | The lock context used for _Scheduler_Acquire_critical().

## ◆ _Scheduler_Release_job()

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.

Parameters

  the_thread | The thread.
  priority_node | The priority node of the job.
  deadline | The deadline in watchdog ticks since boot.
  queue_context | The thread queue context to provide the set of threads for _Thread_Priority_update().

## ◆ _Scheduler_Schedule()

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.

Parameters

  the_thread | The thread which state changed previously.

## ◆ _Scheduler_Set()

RTEMS_INLINE_ROUTINE Status_Control _Scheduler_Set | ( | const Scheduler_Control * | new_scheduler,
|  | Thread_Control * | the_thread,
|  | Priority_Control | priority
| ) |  |

Sets a new scheduler.

Parameters

  | new_scheduler | The new scheduler to set.
  [in,out] | the_thread | The thread for the operations.
  | priority | The initial priority for the thread with the new scheduler.

Return values

  STATUS_SUCCESSFUL | The operation succeeded.
  STATUS_RESOURCE_IN_USE | The thread's wait queue is not empty.
  STATUS_UNSATISFIED | The new scheduler has no processors.

## ◆ _Scheduler_Set_affinity()

bool _Scheduler_Set_affinity | ( | Thread_Control * | the_thread,
|  | size_t | cpusetsize,
|  | const cpu_set_t * | cpuset
| ) |  |

Sets the thread's scheduler's affinity.

Parameters

  [in,out] | the_thread | The thread to set the affinity of.
  | cpusetsize | The size of cpuset.
  | cpuset | The cpuset to set the affinity.

Return values

  true | The operation succeeded.
  false | The operation did not succeed.

## ◆ _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

  | scheduler | The scheduler instance.
  [in,out] | the_thread | The idle thread for the processor.
  [in,out] | cpu | The processor for the idle thread.

See also
  _Thread_Create_idle().

## ◆ _Scheduler_Tick()

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.

Parameters

  cpu | The cpu control for the operation.

## ◆ _Scheduler_Unblock()

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.

Parameters

  the_thread | The thread.

See also
  _Scheduler_Node_get_priority().

## ◆ _Scheduler_Unmap_priority()

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.

Parameters

  scheduler | The scheduler instance.
  priority | The scheduler domain thread priority.

Returns
  The corresponding thread priority of the user domain is returned.

## ◆ _Scheduler_Update_heir()

RTEMS_INLINE_ROUTINE void _Scheduler_Update_heir | ( | Thread_Control * | new_heir,
|  | bool | force_dispatch
| ) |  |

Updates the heir.

Parameters

  [in,out] | new_heir | The new heir.
  | force_dispatch | Indicates whether the dispatch happens also if the currently running thread is set as not preemptible.

## ◆ _Scheduler_Update_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.

Parameters

  the_thread | The thread changing its priority.

See also
  _Scheduler_Node_get_priority().

## ◆ _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

  the_thread | The yielding thread.

## Variable Documentation

## ◆ _Scheduler_Table

const Scheduler_Control _Scheduler_Table[]
| extern

Registered schedulers.

Application provided via <rtems/confdefs.h>.

See also
  _Scheduler_Count.