mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-26 19:38:29 +08:00
score: Add and use Scheduler_simple_Control
This commit is contained in:
@@ -736,7 +736,7 @@ const rtems_libio_helper rtems_fs_init_helper =
|
||||
* define the memory used by the simple scheduler
|
||||
*/
|
||||
#define CONFIGURE_MEMORY_FOR_SCHEDULER ( \
|
||||
_Configure_From_workspace( sizeof(Chain_Control) ) \
|
||||
_Configure_From_workspace( sizeof( Scheduler_simple_Control ) ) \
|
||||
)
|
||||
#define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER (0)
|
||||
#endif
|
||||
|
||||
@@ -54,6 +54,16 @@ extern "C" {
|
||||
_Scheduler_default_Start_idle /* start idle entry point */ \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Simple scheduler control.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* @brief One ready queue for all ready threads.
|
||||
*/
|
||||
Chain_Control Ready;
|
||||
} Scheduler_simple_Control;
|
||||
|
||||
/**
|
||||
* @brief Initialize simple scheduler.
|
||||
*
|
||||
|
||||
@@ -32,6 +32,11 @@ extern "C" {
|
||||
*/
|
||||
/**@{**/
|
||||
|
||||
RTEMS_INLINE_ROUTINE Scheduler_simple_Control *_Scheduler_simple_Instance( void )
|
||||
{
|
||||
return _Scheduler.information;
|
||||
}
|
||||
|
||||
/**
|
||||
* This routine puts @a the_thread on to the ready queue.
|
||||
*
|
||||
@@ -101,9 +106,8 @@ RTEMS_INLINE_ROUTINE void _Scheduler_simple_Schedule_body(
|
||||
bool force_dispatch
|
||||
)
|
||||
{
|
||||
Thread_Control *heir = (Thread_Control *) _Chain_First(
|
||||
(Chain_Control *) _Scheduler.information
|
||||
);
|
||||
Scheduler_simple_Control *scheduler = _Scheduler_simple_Instance();
|
||||
Thread_Control *heir = (Thread_Control *) _Chain_First( &scheduler->Ready );
|
||||
|
||||
( void ) thread;
|
||||
|
||||
|
||||
@@ -25,16 +25,10 @@
|
||||
|
||||
void _Scheduler_simple_Initialize ( void )
|
||||
{
|
||||
void *f;
|
||||
Scheduler_simple_Control *scheduler =
|
||||
_Workspace_Allocate_or_fatal_error( sizeof( *scheduler ) );
|
||||
|
||||
/*
|
||||
* Initialize Ready Queue
|
||||
*/
|
||||
_Chain_Initialize_empty( &scheduler->Ready );
|
||||
|
||||
/* allocate ready queue structures */
|
||||
f = _Workspace_Allocate_or_fatal_error( sizeof(Chain_Control) );
|
||||
_Scheduler.information = f;
|
||||
|
||||
/* initialize ready queue structure */
|
||||
_Chain_Initialize_empty( (Chain_Control *)f );
|
||||
_Scheduler.information = scheduler;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ void _Scheduler_simple_Ready_queue_enqueue(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
Chain_Control *ready = (Chain_Control *) _Scheduler.information;
|
||||
Scheduler_simple_Control *scheduler =
|
||||
_Scheduler_simple_Instance();
|
||||
|
||||
_Scheduler_simple_Insert_priority_fifo( ready, the_thread );
|
||||
_Scheduler_simple_Insert_priority_fifo( &scheduler->Ready, the_thread );
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ void _Scheduler_simple_Ready_queue_enqueue_first(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
Chain_Control *ready = (Chain_Control *) _Scheduler.information;
|
||||
Scheduler_simple_Control *scheduler =
|
||||
_Scheduler_simple_Instance();
|
||||
|
||||
_Scheduler_simple_Insert_priority_lifo( ready, the_thread );
|
||||
_Scheduler_simple_Insert_priority_lifo( &scheduler->Ready, the_thread );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user