RTEMS
Modules | Files | Classes | Typedefs | Enumerations | Functions

SMP Scheduler. More...

Modules

 EDF Priority SMP Scheduler
 EDF Priority SMP Scheduler.
 

Files

file  schedulersmp.h
 SMP Scheduler API.
 
file  schedulersmpimpl.h
 SMP Scheduler Implementation.
 

Classes

struct  Scheduler_SMP_Context
 Scheduler context specialization for SMP schedulers. More...
 
struct  Scheduler_SMP_Node
 Scheduler node specialization for SMP schedulers. More...
 

Typedefs

typedef bool(* Scheduler_SMP_Has_ready) (Scheduler_Context *context)
 
typedef Scheduler_Node *(* Scheduler_SMP_Get_highest_ready) (Scheduler_Context *context, Scheduler_Node *node)
 
typedef Scheduler_Node *(* Scheduler_SMP_Get_lowest_scheduled) (Scheduler_Context *context, Scheduler_Node *filter)
 
typedef void(* Scheduler_SMP_Extract) (Scheduler_Context *context, Scheduler_Node *node_to_extract)
 
typedef void(* Scheduler_SMP_Insert) (Scheduler_Context *context, Scheduler_Node *node_to_insert, Priority_Control insert_priority)
 
typedef void(* Scheduler_SMP_Move) (Scheduler_Context *context, Scheduler_Node *node_to_move)
 
typedef bool(* Scheduler_SMP_Ask_for_help) (Scheduler_Context *context, Thread_Control *thread, Scheduler_Node *node)
 
typedef void(* Scheduler_SMP_Update) (Scheduler_Context *context, Scheduler_Node *node_to_update, Priority_Control new_priority)
 
typedef void(* Scheduler_SMP_Set_affinity) (Scheduler_Context *context, Scheduler_Node *node, void *arg)
 
typedef bool(* Scheduler_SMP_Enqueue) (Scheduler_Context *context, Scheduler_Node *node_to_enqueue, Priority_Control priority)
 
typedef void(* Scheduler_SMP_Allocate_processor) (Scheduler_Context *context, Scheduler_Node *scheduled, Scheduler_Node *victim, Per_CPU_Control *victim_cpu)
 
typedef void(* Scheduler_SMP_Register_idle) (Scheduler_Context *context, Scheduler_Node *idle, Per_CPU_Control *cpu)
 

Enumerations

enum  Scheduler_SMP_Node_state { SCHEDULER_SMP_NODE_BLOCKED, SCHEDULER_SMP_NODE_SCHEDULED, SCHEDULER_SMP_NODE_READY }
 SMP scheduler node states. More...
 

Functions

void _Scheduler_SMP_Start_idle (const Scheduler_Control *scheduler, Thread_Control *idle, struct Per_CPU_Control *cpu)
 Starts an idle thread on the specified cpu. More...
 
static void _Scheduler_SMP_Do_nothing_register_idle (Scheduler_Context *context, Scheduler_Node *idle, Per_CPU_Control *cpu)
 Does nothing. More...
 
static bool _Scheduler_SMP_Priority_less_equal (const void *to_insert, const Chain_Node *next)
 Checks if to_insert is less or equal than the priority of the chain node. More...
 
static Scheduler_SMP_Context_Scheduler_SMP_Get_self (Scheduler_Context *context)
 Gets the scheduler smp context. More...
 
static void _Scheduler_SMP_Initialize (Scheduler_SMP_Context *self)
 Initializes the scheduler smp context. More...
 
static Scheduler_SMP_Node_Scheduler_SMP_Thread_get_node (Thread_Control *thread)
 Gets the scheduler smp node of the thread. More...
 
static Scheduler_SMP_Node_Scheduler_SMP_Thread_get_own_node (Thread_Control *thread)
 Gets the scheduler smp node of the thread. More...
 
static Scheduler_SMP_Node_Scheduler_SMP_Node_downcast (Scheduler_Node *node)
 Gets the scheduler smp node. More...
 
static Scheduler_SMP_Node_state _Scheduler_SMP_Node_state (const Scheduler_Node *node)
 Gets the state of the node. More...
 
static Priority_Control _Scheduler_SMP_Node_priority (const Scheduler_Node *node)
 Gets the priority of the node. More...
 
static void _Scheduler_SMP_Node_initialize (const Scheduler_Control *scheduler, Scheduler_SMP_Node *node, Thread_Control *thread, Priority_Control priority)
 Initializes the scheduler smp node. More...
 
static void _Scheduler_SMP_Node_update_priority (Scheduler_SMP_Node *node, Priority_Control new_priority)
 Updates the priority of the node to the new priority. More...
 
static void _Scheduler_SMP_Node_change_state (Scheduler_Node *node, Scheduler_SMP_Node_state new_state)
 Changes the state of the node to the given state. More...
 
static bool _Scheduler_SMP_Is_processor_owned_by_us (const Scheduler_Context *context, const Per_CPU_Control *cpu)
 Checks if the processor is owned by the given context. More...
 
static Thread_Control_Scheduler_SMP_Get_idle_thread (Scheduler_Context *context)
 Gets The first idle thread of the given context. More...
 
static void _Scheduler_SMP_Release_idle_thread (Scheduler_Context *context, Thread_Control *idle)
 Releases the thread and adds it to the idle threads. More...
 
static void _Scheduler_SMP_Exctract_idle_thread (Thread_Control *idle)
 Extracts the node of the idle thread. More...
 
static void _Scheduler_SMP_Allocate_processor_lazy (Scheduler_Context *context, Scheduler_Node *scheduled, Scheduler_Node *victim, Per_CPU_Control *victim_cpu)
 Allocates the cpu for the scheduled thread. More...
 
static void _Scheduler_SMP_Allocate_processor_exact (Scheduler_Context *context, Scheduler_Node *scheduled, Scheduler_Node *victim, Per_CPU_Control *victim_cpu)
 Allocates the cpu for the scheduled thread. More...
 
static void _Scheduler_SMP_Allocate_processor (Scheduler_Context *context, Scheduler_Node *scheduled, Scheduler_Node *victim, Per_CPU_Control *victim_cpu, Scheduler_SMP_Allocate_processor allocate_processor)
 Allocates the cpu for the scheduled thread using the given allocation function. More...
 
static Thread_Control_Scheduler_SMP_Preempt (Scheduler_Context *context, Scheduler_Node *scheduled, Scheduler_Node *victim, Scheduler_SMP_Allocate_processor allocate_processor)
 Preempts the victim's thread and allocates a cpu for the scheduled thread. More...
 
static Scheduler_Node_Scheduler_SMP_Get_lowest_scheduled (Scheduler_Context *context, Scheduler_Node *filter)
 Returns the lowest member of the scheduled nodes. More...
 
static void _Scheduler_SMP_Enqueue_to_scheduled (Scheduler_Context *context, Scheduler_Node *node, Priority_Control priority, Scheduler_Node *lowest_scheduled, Scheduler_SMP_Insert insert_scheduled, Scheduler_SMP_Move move_from_scheduled_to_ready, Scheduler_SMP_Allocate_processor allocate_processor)
 Tries to schedule the given node. More...
 
static bool _Scheduler_SMP_Enqueue (Scheduler_Context *context, Scheduler_Node *node, Priority_Control insert_priority, Chain_Node_order order, Scheduler_SMP_Insert insert_ready, Scheduler_SMP_Insert insert_scheduled, Scheduler_SMP_Move move_from_scheduled_to_ready, Scheduler_SMP_Get_lowest_scheduled get_lowest_scheduled, Scheduler_SMP_Allocate_processor allocate_processor)
 Enqueues a node according to the specified order function. More...
 
static bool _Scheduler_SMP_Enqueue_scheduled (Scheduler_Context *context, Scheduler_Node *const node, Priority_Control insert_priority, Chain_Node_order order, Scheduler_SMP_Extract extract_from_ready, Scheduler_SMP_Get_highest_ready get_highest_ready, Scheduler_SMP_Insert insert_ready, Scheduler_SMP_Insert insert_scheduled, Scheduler_SMP_Move move_from_ready_to_scheduled, Scheduler_SMP_Allocate_processor allocate_processor)
 Enqueues a scheduled node according to the specified order function. More...
 
static void _Scheduler_SMP_Extract_from_scheduled (Scheduler_Context *context, Scheduler_Node *node)
 Extracts a scheduled node from the scheduled nodes. More...
 
static void _Scheduler_SMP_Schedule_highest_ready (Scheduler_Context *context, Scheduler_Node *victim, Per_CPU_Control *victim_cpu, Scheduler_SMP_Extract extract_from_ready, Scheduler_SMP_Get_highest_ready get_highest_ready, Scheduler_SMP_Move move_from_ready_to_scheduled, Scheduler_SMP_Allocate_processor allocate_processor)
 Schedules the highest ready node. More...
 
static void _Scheduler_SMP_Preempt_and_schedule_highest_ready (Scheduler_Context *context, Scheduler_Node *victim, Per_CPU_Control *victim_cpu, Scheduler_SMP_Extract extract_from_ready, Scheduler_SMP_Get_highest_ready get_highest_ready, Scheduler_SMP_Move move_from_ready_to_scheduled, Scheduler_SMP_Allocate_processor allocate_processor)
 Schedules the highest ready node and preempts a currently executing one. More...
 
static void _Scheduler_SMP_Block (Scheduler_Context *context, Thread_Control *thread, Scheduler_Node *node, Scheduler_SMP_Extract extract_from_scheduled, Scheduler_SMP_Extract extract_from_ready, Scheduler_SMP_Get_highest_ready get_highest_ready, Scheduler_SMP_Move move_from_ready_to_scheduled, Scheduler_SMP_Allocate_processor allocate_processor)
 Blocks the thread. More...
 
static void _Scheduler_SMP_Unblock (Scheduler_Context *context, Thread_Control *thread, Scheduler_Node *node, Scheduler_SMP_Update update, Scheduler_SMP_Enqueue enqueue)
 Unblocks the thread. More...
 
static void _Scheduler_SMP_Update_priority (Scheduler_Context *context, Thread_Control *thread, Scheduler_Node *node, Scheduler_SMP_Extract extract_from_ready, Scheduler_SMP_Update update, Scheduler_SMP_Enqueue enqueue, Scheduler_SMP_Enqueue enqueue_scheduled, Scheduler_SMP_Ask_for_help ask_for_help)
 Updates the priority of the node and the position in the queues it is in. More...
 
static void _Scheduler_SMP_Yield (Scheduler_Context *context, Thread_Control *thread, Scheduler_Node *node, Scheduler_SMP_Extract extract_from_ready, Scheduler_SMP_Enqueue enqueue, Scheduler_SMP_Enqueue enqueue_scheduled)
 Performs a yield and asks for help if necessary. More...
 
static void _Scheduler_SMP_Insert_scheduled (Scheduler_Context *context, Scheduler_Node *node_to_insert, Priority_Control priority_to_insert)
 Inserts the node with the given priority into the scheduled nodes. More...
 
static bool _Scheduler_SMP_Ask_for_help (Scheduler_Context *context, Thread_Control *thread, Scheduler_Node *node, Chain_Node_order order, Scheduler_SMP_Insert insert_ready, Scheduler_SMP_Insert insert_scheduled, Scheduler_SMP_Move move_from_scheduled_to_ready, Scheduler_SMP_Get_lowest_scheduled get_lowest_scheduled, Scheduler_SMP_Allocate_processor allocate_processor)
 Asks for help. More...
 
static void _Scheduler_SMP_Reconsider_help_request (Scheduler_Context *context, Thread_Control *thread, Scheduler_Node *node, Scheduler_SMP_Extract extract_from_ready)
 Reconsiders help request. More...
 
static void _Scheduler_SMP_Withdraw_node (Scheduler_Context *context, Thread_Control *thread, Scheduler_Node *node, Thread_Scheduler_state next_state, Scheduler_SMP_Extract extract_from_ready, Scheduler_SMP_Get_highest_ready get_highest_ready, Scheduler_SMP_Move move_from_ready_to_scheduled, Scheduler_SMP_Allocate_processor allocate_processor)
 Withdraws the node. More...
 
static void _Scheduler_SMP_Do_start_idle (Scheduler_Context *context, Thread_Control *idle, Per_CPU_Control *cpu, Scheduler_SMP_Register_idle register_idle)
 Starts the idle thread on the given processor. More...
 
static void _Scheduler_SMP_Add_processor (Scheduler_Context *context, Thread_Control *idle, Scheduler_SMP_Has_ready has_ready, Scheduler_SMP_Enqueue enqueue_scheduled, Scheduler_SMP_Register_idle register_idle)
 Adds the idle thread to the processor. More...
 
static Thread_Control_Scheduler_SMP_Remove_processor (Scheduler_Context *context, Per_CPU_Control *cpu, Scheduler_SMP_Extract extract_from_ready, Scheduler_SMP_Enqueue enqueue)
 Removes an idle thread from the processor. More...
 
static void _Scheduler_SMP_Set_affinity (Scheduler_Context *context, Thread_Control *thread, Scheduler_Node *node, void *arg, Scheduler_SMP_Set_affinity set_affinity, Scheduler_SMP_Extract extract_from_ready, Scheduler_SMP_Get_highest_ready get_highest_ready, Scheduler_SMP_Move move_from_ready_to_scheduled, Scheduler_SMP_Enqueue enqueue, Scheduler_SMP_Allocate_processor allocate_processor)
 Sets the affinity of the node. More...
 

Detailed Description

SMP Scheduler.

The scheduler nodes can be in four states

State transitions are triggered via basic operations

dot_inline_dotgraph_2.png

During system initialization each processor of the scheduler instance starts with an idle thread assigned to it. Lets have a look at an example with two idle threads I and J with priority 5. We also have blocked threads A, B and C with priorities 1, 2 and 3 respectively. The scheduler nodes are ordered with respect to the thread priority from left to right in the below diagrams. The highest priority node (lowest priority number) is the leftmost node. Since the processor assignment is independent of the thread priority the processor indices may move from one state to the other.

dot_inline_dotgraph_3.png

Lets start A. For this an enqueue operation is performed.

dot_inline_dotgraph_4.png

Lets start C.

dot_inline_dotgraph_5.png

Lets start B.

dot_inline_dotgraph_6.png

Lets change the priority of thread A to 4.

dot_inline_dotgraph_7.png

Now perform a blocking operation with thread B. Please note that thread A migrated now from processor 0 to processor 1 and thread C still executes on processor 1.

dot_inline_dotgraph_8.png

Enumeration Type Documentation

◆ Scheduler_SMP_Node_state

SMP scheduler node states.

Enumerator
SCHEDULER_SMP_NODE_BLOCKED 

This scheduler node is blocked.

A scheduler node is blocked if the corresponding thread is not ready.

SCHEDULER_SMP_NODE_SCHEDULED 

The scheduler node is scheduled.

A scheduler node is scheduled if the corresponding thread is ready and the scheduler allocated a processor for it. A scheduled node is assigned to exactly one processor. The count of scheduled nodes in this scheduler instance equals the processor count owned by the scheduler instance.

SCHEDULER_SMP_NODE_READY 

This scheduler node is ready.

A scheduler node is ready if the corresponding thread is ready and the scheduler did not allocate a processor for it.

Definition at line 70 of file schedulersmp.h.

Function Documentation

◆ _Scheduler_SMP_Add_processor()

static void _Scheduler_SMP_Add_processor ( Scheduler_Context context,
Thread_Control idle,
Scheduler_SMP_Has_ready  has_ready,
Scheduler_SMP_Enqueue  enqueue_scheduled,
Scheduler_SMP_Register_idle  register_idle 
)
inlinestatic

Adds the idle thread to the processor.

Parameters
contextThe scheduler context instance.
[in,out]idleThe idle thread to add to the processor.
has_readyFunction that checks if a given context has ready threads.
enqueue_scheduledFunction to enqueue a scheduled node.
register_idleFunction to register the idle thread for a cpu.

Definition at line 1674 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Allocate_processor()

static void _Scheduler_SMP_Allocate_processor ( Scheduler_Context context,
Scheduler_Node scheduled,
Scheduler_Node victim,
Per_CPU_Control victim_cpu,
Scheduler_SMP_Allocate_processor  allocate_processor 
)
inlinestatic

Allocates the cpu for the scheduled thread using the given allocation function.

Parameters
contextThe scheduler context instance.
scheduledThe scheduled node that should be executed next.
victimIf the heir is this node's thread, no processor is allocated.
[in,out]victim_cpuThe cpu to allocate.
allocate_processorThe function to use for the allocation of victim_cpu.

Definition at line 685 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Allocate_processor_exact()

static void _Scheduler_SMP_Allocate_processor_exact ( Scheduler_Context context,
Scheduler_Node scheduled,
Scheduler_Node victim,
Per_CPU_Control victim_cpu 
)
inlinestatic

Allocates the cpu for the scheduled thread.

This method is slightly different from _Scheduler_SMP_Allocate_processor_lazy() in that it does what it is asked to do. _Scheduler_SMP_Allocate_processor_lazy() attempts to prevent migrations but does not take into account affinity.

Parameters
contextThis parameter is unused.
scheduledThe scheduled node whose thread should be executed next.
victimThis parameter is unused.
[in,out]victim_cpuThe cpu to allocate.

Definition at line 659 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Allocate_processor_lazy()

static void _Scheduler_SMP_Allocate_processor_lazy ( Scheduler_Context context,
Scheduler_Node scheduled,
Scheduler_Node victim,
Per_CPU_Control victim_cpu 
)
inlinestatic

Allocates the cpu for the scheduled thread.

Attempts to prevent migrations but does not take into account affinity.

Parameters
contextThe scheduler context instance.
scheduledThe scheduled node that should be executed next.
victimIf the heir is this node's thread, no processor is allocated.
[in,out]victim_cpuThe cpu to allocate.

Definition at line 609 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Ask_for_help()

static bool _Scheduler_SMP_Ask_for_help ( Scheduler_Context context,
Thread_Control thread,
Scheduler_Node node,
Chain_Node_order  order,
Scheduler_SMP_Insert  insert_ready,
Scheduler_SMP_Insert  insert_scheduled,
Scheduler_SMP_Move  move_from_scheduled_to_ready,
Scheduler_SMP_Get_lowest_scheduled  get_lowest_scheduled,
Scheduler_SMP_Allocate_processor  allocate_processor 
)
inlinestatic

Asks for help.

Parameters
contextThe scheduler instance context.
threadThe thread that asks for help.
[in,out]nodeThe node of the thread that performs the ask for help operation.
orderThe order function.
insert_readyFunction to insert a node into the set of ready nodes.
insert_scheduledFunction to insert a node into the set of scheduled nodes.
move_from_scheduled_to_readyFunction to move a node from the set of scheduled nodes to the set of ready nodes.
get_lowest_scheduledFunction to select the node from the scheduled nodes to replace.
allocate_processorFunction to allocate a processor to a node based on the rules of the scheduler.
Return values
trueThe ask for help operation was successful.
falseThe ask for help operation was not successful.

Definition at line 1449 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Block()

static void _Scheduler_SMP_Block ( Scheduler_Context context,
Thread_Control thread,
Scheduler_Node node,
Scheduler_SMP_Extract  extract_from_scheduled,
Scheduler_SMP_Extract  extract_from_ready,
Scheduler_SMP_Get_highest_ready  get_highest_ready,
Scheduler_SMP_Move  move_from_ready_to_scheduled,
Scheduler_SMP_Allocate_processor  allocate_processor 
)
inlinestatic

Blocks the thread.

Parameters
contextThe scheduler instance context.
[in,out]threadThe thread of the scheduling operation.
[in,out]nodeThe scheduler node of the thread to block.
extract_from_scheduledFunction to extract a node from the set of scheduled nodes.
extract_from_readyFunction to extract a node from the set of ready nodes.
get_highest_readyFunction to get the highest ready node.
move_from_ready_to_scheduledFunction to move a node from the set of ready nodes to the set of scheduled nodes.
allocate_processorFunction to allocate a processor to a node based on the rules of the scheduler.

Definition at line 1189 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Do_nothing_register_idle()

static void _Scheduler_SMP_Do_nothing_register_idle ( Scheduler_Context context,
Scheduler_Node idle,
Per_CPU_Control cpu 
)
inlinestatic

Does nothing.

Parameters
contextThis parameter is unused.
idleThis parameter is unused.
cpuThis parameter is unused.

Definition at line 352 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Do_start_idle()

static void _Scheduler_SMP_Do_start_idle ( Scheduler_Context context,
Thread_Control idle,
Per_CPU_Control cpu,
Scheduler_SMP_Register_idle  register_idle 
)
inlinestatic

Starts the idle thread on the given processor.

Parameters
contextThe scheduler context instance.
[in,out]idleThe idle thread to schedule.
cpuThe processor for the idle thread.
register_idleFunction to register the idle thread for a cpu.

Definition at line 1643 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Enqueue()

static bool _Scheduler_SMP_Enqueue ( Scheduler_Context context,
Scheduler_Node node,
Priority_Control  insert_priority,
Chain_Node_order  order,
Scheduler_SMP_Insert  insert_ready,
Scheduler_SMP_Insert  insert_scheduled,
Scheduler_SMP_Move  move_from_scheduled_to_ready,
Scheduler_SMP_Get_lowest_scheduled  get_lowest_scheduled,
Scheduler_SMP_Allocate_processor  allocate_processor 
)
inlinestatic

Enqueues a node according to the specified order function.

The node must not be in the scheduled state.

Parameters
contextThe scheduler instance context.
[in,out]nodeThe node to enqueue.
priorityThe node insert priority.
orderThe order function.
insert_readyFunction to insert a node into the set of ready nodes.
insert_scheduledFunction to insert a node into the set of scheduled nodes.
move_from_scheduled_to_readyFunction to move a node from the set of scheduled nodes to the set of ready nodes.
get_lowest_scheduledFunction to select the node from the scheduled nodes to replace. It may not be possible to find one, in this case a pointer must be returned so that the order functions returns false if this pointer is passed as the second argument to the order function.
allocate_processorFunction to allocate a processor to a node based on the rules of the scheduler.

Definition at line 875 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Enqueue_scheduled()

static bool _Scheduler_SMP_Enqueue_scheduled ( Scheduler_Context context,
Scheduler_Node *const  node,
Priority_Control  insert_priority,
Chain_Node_order  order,
Scheduler_SMP_Extract  extract_from_ready,
Scheduler_SMP_Get_highest_ready  get_highest_ready,
Scheduler_SMP_Insert  insert_ready,
Scheduler_SMP_Insert  insert_scheduled,
Scheduler_SMP_Move  move_from_ready_to_scheduled,
Scheduler_SMP_Allocate_processor  allocate_processor 
)
inlinestatic

Enqueues a scheduled node according to the specified order function.

Parameters
contextThe scheduler instance context.
[in,out]nodeThe node to enqueue.
orderThe order function.
extract_from_readyFunction to extract a node from the set of ready nodes.
get_highest_readyFunction to get the highest ready node.
insert_readyFunction to insert a node into the set of ready nodes.
insert_scheduledFunction to insert a node into the set of scheduled nodes.
move_from_ready_to_scheduledFunction to move a node from the set of ready nodes to the set of scheduled nodes.
allocate_processorFunction to allocate a processor to a node based on the rules of the scheduler.

Definition at line 930 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Enqueue_to_scheduled()

static void _Scheduler_SMP_Enqueue_to_scheduled ( Scheduler_Context context,
Scheduler_Node node,
Priority_Control  priority,
Scheduler_Node lowest_scheduled,
Scheduler_SMP_Insert  insert_scheduled,
Scheduler_SMP_Move  move_from_scheduled_to_ready,
Scheduler_SMP_Allocate_processor  allocate_processor 
)
inlinestatic

Tries to schedule the given node.

Schedules the node, or blocks if that is necessary.

Parameters
contextThe scheduler context instance.
[in,out]nodeThe node to insert into the scheduled nodes.
priorityThe priority of node.
[in,out]lowest_scheduledThe lowest member of the scheduled nodes.
insert_scheduledFunction to insert a node into the set of scheduled nodes.
move_from_scheduled_to_readyFunction to move a node from the set of scheduled nodes to the set of ready nodes.
allocate_processorFunction to allocate a processor to a node based on the rules of the scheduler.

Definition at line 797 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Exctract_idle_thread()

static void _Scheduler_SMP_Exctract_idle_thread ( Thread_Control idle)
inlinestatic

Extracts the node of the idle thread.

Parameters
[in,out]idleThe thread to extract the node of.

Definition at line 592 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Extract_from_scheduled()

static void _Scheduler_SMP_Extract_from_scheduled ( Scheduler_Context context,
Scheduler_Node node 
)
inlinestatic

Extracts a scheduled node from the scheduled nodes.

Parameters
contextThis parameter is unused.
nodeThe node to extract from the chain it belongs to.

Definition at line 1047 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Get_idle_thread()

static Thread_Control* _Scheduler_SMP_Get_idle_thread ( Scheduler_Context context)
inlinestatic

Gets The first idle thread of the given context.

Parameters
contextThe scheduler context to get the first idle thread from.
Returns
The first idle thread of context.

Definition at line 558 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Get_lowest_scheduled()

static Scheduler_Node* _Scheduler_SMP_Get_lowest_scheduled ( Scheduler_Context context,
Scheduler_Node filter 
)
inlinestatic

Returns the lowest member of the scheduled nodes.

Parameters
contextThe scheduler context instance.
filterThis parameter is unused.
Returns
The lowest scheduled node.

Definition at line 761 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Get_self()

static Scheduler_SMP_Context* _Scheduler_SMP_Get_self ( Scheduler_Context context)
inlinestatic

Gets the scheduler smp context.

Parameters
contextThe context to cast to Scheduler_SMP_Context *.
Returns
context cast to Scheduler_SMP_Context *.

Definition at line 393 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Initialize()

static void _Scheduler_SMP_Initialize ( Scheduler_SMP_Context self)
inlinestatic

Initializes the scheduler smp context.

Parameters
[out]selfThe context to initialize.

Definition at line 405 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Insert_scheduled()

static void _Scheduler_SMP_Insert_scheduled ( Scheduler_Context context,
Scheduler_Node node_to_insert,
Priority_Control  priority_to_insert 
)
inlinestatic

Inserts the node with the given priority into the scheduled nodes.

Parameters
contextThe scheduler instance context.
node_to_insertThe scheduled node to insert.
priority_to_insertThe priority with which to insert the node.

Definition at line 1409 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Is_processor_owned_by_us()

static bool _Scheduler_SMP_Is_processor_owned_by_us ( const Scheduler_Context context,
const Per_CPU_Control cpu 
)
inlinestatic

Checks if the processor is owned by the given context.

Parameters
contextThe context to check whether cpu is owned by it.
cpuThe cpu to check whether it is owned by context.
Return values
truecpu is owned by context.
falsecpu is not owned by context.

Definition at line 543 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Node_change_state()

static void _Scheduler_SMP_Node_change_state ( Scheduler_Node node,
Scheduler_SMP_Node_state  new_state 
)
inlinestatic

Changes the state of the node to the given state.

Parameters
[out]nodethe node to change the state of.
new_stateThe new state for node.

Definition at line 523 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Node_downcast()

static Scheduler_SMP_Node* _Scheduler_SMP_Node_downcast ( Scheduler_Node node)
inlinestatic

Gets the scheduler smp node.

Parameters
nodeThe node to cast to Scheduler_SMP_Node *.
Returns
node cast to Scheduler_SMP_Node *.

Definition at line 448 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Node_initialize()

static void _Scheduler_SMP_Node_initialize ( const Scheduler_Control scheduler,
Scheduler_SMP_Node node,
Thread_Control thread,
Priority_Control  priority 
)
inlinestatic

Initializes the scheduler smp node.

Parameters
schedulerThe scheduler instance.
[out]nodeThe node to initialize.
threadThe thread of the scheduler smp node.
priorityThe priority to initialize node with.

Definition at line 491 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Node_priority()

static Priority_Control _Scheduler_SMP_Node_priority ( const Scheduler_Node node)
inlinestatic

Gets the priority of the node.

Parameters
nodeThe node to get the priority of.
Returns
The priority of node.

Definition at line 476 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Node_state()

static Scheduler_SMP_Node_state _Scheduler_SMP_Node_state ( const Scheduler_Node node)
inlinestatic

Gets the state of the node.

Parameters
nodeThe node to get the state of.
Returns
The state of node.

Definition at line 462 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Node_update_priority()

static void _Scheduler_SMP_Node_update_priority ( Scheduler_SMP_Node node,
Priority_Control  new_priority 
)
inlinestatic

Updates the priority of the node to the new priority.

Parameters
[out]nodeThe node to update the priority of.
new_priorityThe new priority for node.

Definition at line 509 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Preempt()

static Thread_Control* _Scheduler_SMP_Preempt ( Scheduler_Context context,
Scheduler_Node scheduled,
Scheduler_Node victim,
Scheduler_SMP_Allocate_processor  allocate_processor 
)
inlinestatic

Preempts the victim's thread and allocates a cpu for the scheduled thread.

Parameters
contextThe scheduler context instance.
scheduledNode of the scheduled thread that is about to be executed.
[in,out]victimNode of the thread to preempt.
allocate_processorThe function for allocation of a processor for the new thread.
Returns
The preempted thread.

Definition at line 707 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Preempt_and_schedule_highest_ready()

static void _Scheduler_SMP_Preempt_and_schedule_highest_ready ( Scheduler_Context context,
Scheduler_Node victim,
Per_CPU_Control victim_cpu,
Scheduler_SMP_Extract  extract_from_ready,
Scheduler_SMP_Get_highest_ready  get_highest_ready,
Scheduler_SMP_Move  move_from_ready_to_scheduled,
Scheduler_SMP_Allocate_processor  allocate_processor 
)
inlinestatic

Schedules the highest ready node and preempts a currently executing one.

Parameters
contextThe scheduler context instance.
victimThe node of the thread that is repressed by the newly scheduled thread.
victim_cpuThe cpu to allocate.
extract_from_readyFunction to extract a node from the set of ready nodes.
get_highest_readyFunction to get the highest ready node.
move_from_ready_to_scheduledFunction to move a node from the set of ready nodes to the set of scheduled nodes.
allocate_processorFunction to allocate a processor to a node based on the rules of the scheduler.

Definition at line 1129 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Priority_less_equal()

static bool _Scheduler_SMP_Priority_less_equal ( const void *  to_insert,
const Chain_Node next 
)
inlinestatic

Checks if to_insert is less or equal than the priority of the chain node.

Parameters
to_insertThe priority to compare.
nextThe chain node to compare the priority of.
Return values
trueto_insert is less or equal than the priority of next.
falseto_insert is greater than the priority of next.

Definition at line 372 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Reconsider_help_request()

static void _Scheduler_SMP_Reconsider_help_request ( Scheduler_Context context,
Thread_Control thread,
Scheduler_Node node,
Scheduler_SMP_Extract  extract_from_ready 
)
inlinestatic

Reconsiders help request.

Parameters
contextThe scheduler context instance.
threadThe thread to reconsider the help request of.
[in,out]nodeThe scheduler node of thread.
extract_from_readyFunction to extract a node from the ready queue of the scheduler context.

Definition at line 1552 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Release_idle_thread()

static void _Scheduler_SMP_Release_idle_thread ( Scheduler_Context context,
Thread_Control idle 
)
inlinestatic

Releases the thread and adds it to the idle threads.

Parameters
[in,out]contextThe scheduler context instance.
idleThe thread to add to the idle threads.

Definition at line 577 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Remove_processor()

static Thread_Control* _Scheduler_SMP_Remove_processor ( Scheduler_Context context,
Per_CPU_Control cpu,
Scheduler_SMP_Extract  extract_from_ready,
Scheduler_SMP_Enqueue  enqueue 
)
inlinestatic

Removes an idle thread from the processor.

Parameters
contextThe scheduler context instance.
cpuThe processor to remove from.
extract_from_readyFunction to extract a node from the ready queue of the scheduler context.
enqueueFunction to enqueue a node with a given priority.
Returns
The idle thread of cpu.

Definition at line 1714 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Schedule_highest_ready()

static void _Scheduler_SMP_Schedule_highest_ready ( Scheduler_Context context,
Scheduler_Node victim,
Per_CPU_Control victim_cpu,
Scheduler_SMP_Extract  extract_from_ready,
Scheduler_SMP_Get_highest_ready  get_highest_ready,
Scheduler_SMP_Move  move_from_ready_to_scheduled,
Scheduler_SMP_Allocate_processor  allocate_processor 
)
inlinestatic

Schedules the highest ready node.

Parameters
contextThe scheduler context instance.
victimThe node of the thread that is repressed by the newly scheduled thread.
victim_cpuThe cpu to allocate.
extract_from_readyFunction to extract a node from the set of ready nodes.
get_highest_readyFunction to get the highest ready node.
move_from_ready_to_scheduledFunction to move a node from the set of ready nodes to the set of scheduled nodes.
allocate_processorFunction to allocate a processor to a node based on the rules of the scheduler.

Definition at line 1070 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Set_affinity()

static void _Scheduler_SMP_Set_affinity ( Scheduler_Context context,
Thread_Control thread,
Scheduler_Node node,
void *  arg,
Scheduler_SMP_Set_affinity  set_affinity,
Scheduler_SMP_Extract  extract_from_ready,
Scheduler_SMP_Get_highest_ready  get_highest_ready,
Scheduler_SMP_Move  move_from_ready_to_scheduled,
Scheduler_SMP_Enqueue  enqueue,
Scheduler_SMP_Allocate_processor  allocate_processor 
)
inlinestatic

Sets the affinity of the node.

Also performs a reinsert into the queue the node is currently in.

Parameters
contextThe scheduler context instance.
threadThe thread for the operation.
[in,out]nodeThe node to set the affinity of.
argThe affinity for node.
set_affinityFunction to set the affinity of a node.
extract_from_readyFunction to extract a node from the ready queue of the scheduler context.
get_highest_readyFunction to get the highest ready node.
move_from_ready_to_scheduledFunction to move a node from the set of ready nodes to the set of scheduled nodes.
enqueueFunction to enqueue a node with a given priority.
allocate_processorFunction to allocate a processor to a node based on the rules of the scheduler.

Definition at line 1795 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Start_idle()

void _Scheduler_SMP_Start_idle ( const Scheduler_Control scheduler,
Thread_Control idle,
struct Per_CPU_Control cpu 
)

Starts an idle thread on the specified cpu.

Parameters
schedulerThe scheduler instance.
[in,out]idleThe idle thread to schedule.
[out]cpuThe cpu to run the idle thread on.

Definition at line 15 of file schedulersmpstartidle.c.

◆ _Scheduler_SMP_Thread_get_node()

static Scheduler_SMP_Node* _Scheduler_SMP_Thread_get_node ( Thread_Control thread)
inlinestatic

Gets the scheduler smp node of the thread.

Parameters
threadThe thread to get the smp node of.
Returns
The scheduler smp node of thread.

Definition at line 420 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Thread_get_own_node()

static Scheduler_SMP_Node* _Scheduler_SMP_Thread_get_own_node ( Thread_Control thread)
inlinestatic

Gets the scheduler smp node of the thread.

Parameters
threadThe thread to get the smp node of.
Returns
The scheduler smp node of thread.

Definition at line 434 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Unblock()

static void _Scheduler_SMP_Unblock ( Scheduler_Context context,
Thread_Control thread,
Scheduler_Node node,
Scheduler_SMP_Update  update,
Scheduler_SMP_Enqueue  enqueue 
)
inlinestatic

Unblocks the thread.

Parameters
contextThe scheduler instance context.
[in,out]threadThe thread of the scheduling operation.
[in,out]nodeThe scheduler node of the thread to block.
updateFunction to update the node's priority to the new value.
enqueueFunction to insert a node with a priority in the ready queue of a context.

Definition at line 1243 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Update_priority()

static void _Scheduler_SMP_Update_priority ( Scheduler_Context context,
Thread_Control thread,
Scheduler_Node node,
Scheduler_SMP_Extract  extract_from_ready,
Scheduler_SMP_Update  update,
Scheduler_SMP_Enqueue  enqueue,
Scheduler_SMP_Enqueue  enqueue_scheduled,
Scheduler_SMP_Ask_for_help  ask_for_help 
)
inlinestatic

Updates the priority of the node and the position in the queues it is in.

This function firstly updates the priority of the node and then extracts and reinserts it into the queue the node is part of using the given functions.

Parameters
contextThe scheduler instance context.
threadThe thread for the operation.
[in,out]nodeThe node to update the priority of.
extract_from_readyFunction to extract a node from the ready queue of the scheduler context.
updateFunction to update the priority of a node in the scheduler context.
enqueueFunction to enqueue a node with a given priority.
enqueue_scheduledFunction to enqueue a scheduled node.
ask_for_helpFunction to perform a help request.

Definition at line 1312 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Withdraw_node()

static void _Scheduler_SMP_Withdraw_node ( Scheduler_Context context,
Thread_Control thread,
Scheduler_Node node,
Thread_Scheduler_state  next_state,
Scheduler_SMP_Extract  extract_from_ready,
Scheduler_SMP_Get_highest_ready  get_highest_ready,
Scheduler_SMP_Move  move_from_ready_to_scheduled,
Scheduler_SMP_Allocate_processor  allocate_processor 
)
inlinestatic

Withdraws the node.

Parameters
contextThe scheduler context instance.
[in,out]threadThe thread to change to next_state.
[in,out]nodeThe node to withdraw.
next_stateThe new state for thread.
extract_from_readyFunction to extract a node from the ready queue of the scheduler context.
get_highest_readyFunction to get the highest ready node.
move_from_ready_to_scheduledFunction to move a node from the set of ready nodes to the set of scheduled nodes.
allocate_processorFunction to allocate a processor to a node based on the rules of the scheduler.

Definition at line 1590 of file schedulersmpimpl.h.

◆ _Scheduler_SMP_Yield()

static void _Scheduler_SMP_Yield ( Scheduler_Context context,
Thread_Control thread,
Scheduler_Node node,
Scheduler_SMP_Extract  extract_from_ready,
Scheduler_SMP_Enqueue  enqueue,
Scheduler_SMP_Enqueue  enqueue_scheduled 
)
inlinestatic

Performs a yield and asks for help if necessary.

Parameters
contextThe scheduler instance context.
threadThe thread for the operation.
nodeThe node of the thread that yields.
extract_from_readyFunction to extract a node from the ready queue of the scheduler context.
enqueueFunction to enqueue a node with a given priority.
enqueue_scheduledFunction to enqueue a scheduled node.

Definition at line 1368 of file schedulersmpimpl.h.