RTEMS CPU Kit with SuperCore  4.10.99.0
Data Structures | Modules | Defines | Functions | Variables
Scheduler Handler
SuperCore

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

Collaboration diagram for Scheduler Handler:

Data Structures

struct  Scheduler_Operations
 function jump table that holds pointers to the functions that implement specific schedulers. More...
struct  Scheduler_Control
 This is the structure used to manage the scheduler. More...

Modules

 CBS Scheduler
 EDF Scheduler
 Deterministic Priority-based Scheduler
 Simple Priority Scheduler
 Simple SMP Scheduler
 

The Simple SMP Scheduler attempts to faithfully implement the behaviour of the Deterministic Priority Scheduler while spreading the threads across multiple cores.


Defines

#define _Scheduler_Is_priority_lower_than(_p1, _p2)   (_Scheduler_Priority_compare(_p1,_p2) < 0)
 Macro testing whether p1 has lower priority than p2 in the intuitive sense of priority.
#define _Scheduler_Is_priority_higher_than(_p1, _p2)   (_Scheduler_Priority_compare(_p1,_p2) > 0)
 Macro testing whether p1 has higher priority than p2 in the intuitive sense of priority.

Functions

void _Scheduler_Handler_initialization (void)
 Initializes the scheduler to the policy chosen by the user.
RTEMS_INLINE_ROUTINE void _Scheduler_Schedule (void)
 The preferred method to add a new scheduler is to define the jump table entries and add a case to the _Scheduler_Initialize routine.
RTEMS_INLINE_ROUTINE void _Scheduler_Yield (void)
 Scheduler yield.
RTEMS_INLINE_ROUTINE void _Scheduler_Block (Thread_Control *the_thread)
 Scheduler block.
RTEMS_INLINE_ROUTINE void _Scheduler_Unblock (Thread_Control *the_thread)
 Scheduler unblock.
RTEMS_INLINE_ROUTINE void * _Scheduler_Allocate (Thread_Control *the_thread)
 Scheduler allocate.
RTEMS_INLINE_ROUTINE void _Scheduler_Free (Thread_Control *the_thread)
 Scheduler free.
RTEMS_INLINE_ROUTINE void _Scheduler_Update (Thread_Control *the_thread)
 Scheduler update.
RTEMS_INLINE_ROUTINE void _Scheduler_Enqueue (Thread_Control *the_thread)
 Scheduler enqueue.
RTEMS_INLINE_ROUTINE void _Scheduler_Enqueue_first (Thread_Control *the_thread)
 Scheduler enqueue first.
RTEMS_INLINE_ROUTINE void _Scheduler_Extract (Thread_Control *the_thread)
 Scheduler extract.
RTEMS_INLINE_ROUTINE int _Scheduler_Priority_compare (Priority_Control p1, Priority_Control p2)
 Scheduler priority compare.
RTEMS_INLINE_ROUTINE void _Scheduler_Release_job (Thread_Control *the_thread, uint32_t length)
 Scheduler release job.
RTEMS_INLINE_ROUTINE void _Scheduler_Tick (void)
 Scheduler method invoked at each clock tick.
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize (void)
 Ready queue initialization.
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue (Thread_Control *the_thread)
 Put a thread to the ready queue.
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue_first (Thread_Control *the_thread)
 Put a thread to the head of the ready queue.
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract (Thread_Control *the_thread)
 Remove a specific thread from the ready queue.
RTEMS_INLINE_ROUTINE
Thread_Control
_Scheduler_priority_Ready_queue_first (Chain_Control *the_ready_queue)
 Return a pointer to the first thread.
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_requeue (Thread_Control *the_thread)
 Requeue a thread on the ready queue.
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Schedule_body (void)
 Scheduling decision logic.
RTEMS_INLINE_ROUTINE int _Scheduler_priority_Priority_compare_body (Priority_Control p1, Priority_Control p2)
 Priority comparison.
RTEMS_INLINE_ROUTINE void _Scheduler_simple_Ready_queue_requeue (Scheduler_Control *the_ready_queue, Thread_Control *the_thread)
 This routine puts the_thread on to the ready queue.

Variables

Scheduler_Control _Scheduler
 The _Scheduler holds the structures used to manage the scheduler.

Detailed Description

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


Function Documentation

RTEMS_INLINE_ROUTINE void* _Scheduler_Allocate ( Thread_Control the_thread)

Scheduler allocate.

This routine allocates the_thread->scheduler

References _Scheduler, Scheduler_Control::Operations, and Scheduler_Operations::allocate.

RTEMS_INLINE_ROUTINE void _Scheduler_Block ( Thread_Control the_thread)

Scheduler block.

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.

References _Scheduler, Scheduler_Control::Operations, and Scheduler_Operations::block.

RTEMS_INLINE_ROUTINE void _Scheduler_Enqueue ( Thread_Control the_thread)

Scheduler enqueue.

This routine enqueue the_thread->scheduler

References _Scheduler, Scheduler_Control::Operations, and Scheduler_Operations::enqueue.

RTEMS_INLINE_ROUTINE void _Scheduler_Enqueue_first ( Thread_Control the_thread)

Scheduler enqueue first.

This routine enqueue_first the_thread->scheduler

References _Scheduler, Scheduler_Control::Operations, and Scheduler_Operations::enqueue_first.

RTEMS_INLINE_ROUTINE void _Scheduler_Extract ( Thread_Control the_thread)

Scheduler extract.

This routine extract the_thread->scheduler

References _Scheduler, Scheduler_Control::Operations, and Scheduler_Operations::extract.

RTEMS_INLINE_ROUTINE void _Scheduler_Free ( Thread_Control the_thread)

Scheduler free.

This routine frees the_thread->scheduler

References _Scheduler, Scheduler_Control::Operations, and Scheduler_Operations::free.

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 int _Scheduler_Priority_compare ( Priority_Control  p1,
Priority_Control  p2 
)

Scheduler priority compare.

This routine compares two priorities.

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

RTEMS_INLINE_ROUTINE int _Scheduler_priority_Priority_compare_body ( Priority_Control  p1,
Priority_Control  p2 
)

Priority comparison.

This routine implements priority comparison for priority-based scheduling.

Returns:
>0 for higher priority, 0 for equal and <0 for lower priority.
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue ( Thread_Control the_thread)

Put a thread to the ready queue.

This routine puts the_thread on to the priority-based ready queue.

Parameters:
[in]the_threadis a pointer to the thread

References Thread_Control_struct::scheduler_info, Scheduler_priority_Per_thread::ready_chain, _Priority_bit_map_Add(), Scheduler_priority_Per_thread::Priority_map, _Chain_Append_unprotected(), Thread_Control_struct::Object, and Objects_Control::Node.

RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue_first ( Thread_Control the_thread)

Put a thread to the head of the ready queue.

This routine puts the_thread to the head of the ready queue. For priority-based ready queues, the thread will be the first thread at its priority level.

Parameters:
[in]the_threadis a pointer to the thread.

References Thread_Control_struct::scheduler_info, _Priority_bit_map_Add(), Scheduler_priority_Per_thread::Priority_map, _Chain_Prepend_unprotected(), Scheduler_priority_Per_thread::ready_chain, Thread_Control_struct::Object, and Objects_Control::Node.

RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract ( Thread_Control the_thread)

Remove a specific thread from the ready queue.

This routine removes a specific thread from the specified priority-based ready queue.

Parameters:
[in]the_threadis a pointer to the thread.

References Thread_Control_struct::scheduler_info, Scheduler_priority_Per_thread::ready_chain, _Chain_Has_only_one_node(), _Chain_Initialize_empty(), _Priority_bit_map_Remove(), Scheduler_priority_Per_thread::Priority_map, _Chain_Extract_unprotected(), Thread_Control_struct::Object, and Objects_Control::Node.

RTEMS_INLINE_ROUTINE Thread_Control* _Scheduler_priority_Ready_queue_first ( Chain_Control the_ready_queue)

Return a pointer to the first thread.

This routines returns a pointer to the first thread on the_ready_queue.

Parameters:
[in]the_ready_queue- pointer to thread queue
Returns:
This method returns the first thread or NULL

References _Priority_bit_map_Get_highest(), _Chain_Is_empty(), and _Chain_First().

Referenced by _Scheduler_priority_Schedule_body().

RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize ( void  )

Ready queue initialization.

This routine initializes the_ready_queue for priority-based scheduling.

References _Scheduler, Scheduler_Control::information, _Workspace_Allocate_or_fatal_error(), PRIORITY_MAXIMUM, and _Chain_Initialize_empty().

RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_requeue ( Thread_Control the_thread)

Requeue a thread on the ready queue.

This routine is invoked when a thread changes priority and should be moved to a different position on the ready queue.

Parameters:
[in]the_threadis a pointer to the thread

References Thread_Control_struct::scheduler_info, _Chain_Has_only_one_node(), Scheduler_priority_Per_thread::ready_chain, _Chain_Extract_unprotected(), Thread_Control_struct::Object, Objects_Control::Node, and _Chain_Append_unprotected().

RTEMS_INLINE_ROUTINE void _Scheduler_priority_Schedule_body ( void  )

Scheduling decision logic.

This kernel routine implements scheduling decision logic for priority-based scheduling.

References _Scheduler_priority_Ready_queue_first(), _Scheduler, and Scheduler_Control::information.

RTEMS_INLINE_ROUTINE void _Scheduler_Release_job ( Thread_Control the_thread,
uint32_t  length 
)

Scheduler release job.

This routine is called when a new period of task is issued.

References _Scheduler, Scheduler_Control::Operations, and Scheduler_Operations::release_job.

RTEMS_INLINE_ROUTINE void _Scheduler_Schedule ( void  )

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. Scheduler schedule.

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

References _Scheduler, Scheduler_Control::Operations, and Scheduler_Operations::schedule.

RTEMS_INLINE_ROUTINE void _Scheduler_simple_Ready_queue_requeue ( Scheduler_Control the_ready_queue,
Thread_Control the_thread 
)

This routine puts the_thread on to the ready queue.

Parameters:
[in]the_ready_queueis a pointer to the ready queue head
[in]the_threadis the thread to be blocked

References _Chain_Extract_unprotected(), Thread_Control_struct::Object, Objects_Control::Node, and _Scheduler_simple_Ready_queue_enqueue().

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.

References _Scheduler, Scheduler_Control::Operations, and Scheduler_Operations::tick.

RTEMS_INLINE_ROUTINE void _Scheduler_Unblock ( Thread_Control the_thread)

Scheduler unblock.

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.

References _Scheduler, Scheduler_Control::Operations, and Scheduler_Operations::unblock.

RTEMS_INLINE_ROUTINE void _Scheduler_Update ( Thread_Control the_thread)

Scheduler update.

This routine updates the_thread->scheduler

References _Scheduler, Scheduler_Control::Operations, and Scheduler_Operations::update.

RTEMS_INLINE_ROUTINE void _Scheduler_Yield ( void  )

Scheduler yield.

This routine is invoked when a thread wishes to voluntarily transfer control of the processor to another thread. This routine always operates on the scheduler that 'owns' the currently executing thread.

References _Scheduler, Scheduler_Control::Operations, and Scheduler_Operations::yield.


Variable Documentation