From 439c494fe20f474984c22a333613c33fac5585eb Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 3 Apr 2014 12:02:09 +0200 Subject: score: Add and use Scheduler_simple_Control --- cpukit/sapi/include/confdefs.h | 2 +- cpukit/score/include/rtems/score/schedulersimple.h | 10 ++++++++++ cpukit/score/include/rtems/score/schedulersimpleimpl.h | 10 +++++++--- cpukit/score/src/schedulersimple.c | 14 ++++---------- cpukit/score/src/schedulersimplereadyqueueenqueue.c | 5 +++-- cpukit/score/src/schedulersimplereadyqueueenqueuefirst.c | 5 +++-- 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h index 16049f9d4b..4bfe4e88ff 100644 --- a/cpukit/sapi/include/confdefs.h +++ b/cpukit/sapi/include/confdefs.h @@ -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 diff --git a/cpukit/score/include/rtems/score/schedulersimple.h b/cpukit/score/include/rtems/score/schedulersimple.h index db9c8f3834..54b0801872 100644 --- a/cpukit/score/include/rtems/score/schedulersimple.h +++ b/cpukit/score/include/rtems/score/schedulersimple.h @@ -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. * diff --git a/cpukit/score/include/rtems/score/schedulersimpleimpl.h b/cpukit/score/include/rtems/score/schedulersimpleimpl.h index 25fbbc7b3c..c51c6c3f0e 100644 --- a/cpukit/score/include/rtems/score/schedulersimpleimpl.h +++ b/cpukit/score/include/rtems/score/schedulersimpleimpl.h @@ -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; diff --git a/cpukit/score/src/schedulersimple.c b/cpukit/score/src/schedulersimple.c index 8ea8b538dc..b825b29014 100644 --- a/cpukit/score/src/schedulersimple.c +++ b/cpukit/score/src/schedulersimple.c @@ -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; } diff --git a/cpukit/score/src/schedulersimplereadyqueueenqueue.c b/cpukit/score/src/schedulersimplereadyqueueenqueue.c index 67a2d51e84..134f6e8a7a 100644 --- a/cpukit/score/src/schedulersimplereadyqueueenqueue.c +++ b/cpukit/score/src/schedulersimplereadyqueueenqueue.c @@ -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 ); } diff --git a/cpukit/score/src/schedulersimplereadyqueueenqueuefirst.c b/cpukit/score/src/schedulersimplereadyqueueenqueuefirst.c index 7b8d3382b6..841bcd1a64 100644 --- a/cpukit/score/src/schedulersimplereadyqueueenqueuefirst.c +++ b/cpukit/score/src/schedulersimplereadyqueueenqueuefirst.c @@ -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 ); } -- cgit v1.2.3