[PATCH 2/3] score: Add and use Scheduler_simple_Control
Sebastian Huber
sebastian.huber at embedded-brains.de
Thu Apr 3 14:28:33 UTC 2014
---
cpukit/sapi/include/confdefs.h | 2 +-
cpukit/score/include/rtems/score/schedulersimple.h | 10 ++++++++++
.../include/rtems/score/schedulersimpleimpl.h | 10 +++++++---
cpukit/score/src/schedulersimple.c | 14 ++++----------
.../score/src/schedulersimplereadyqueueenqueue.c | 5 +++--
.../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 aed15fc..294b9bb 100644
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -714,7 +714,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 db9c8f3..54b0801 100644
--- a/cpukit/score/include/rtems/score/schedulersimple.h
+++ b/cpukit/score/include/rtems/score/schedulersimple.h
@@ -55,6 +55,16 @@ extern "C" {
}
/**
+ * @brief Simple scheduler control.
+ */
+typedef struct {
+ /**
+ * @brief One ready queue for all ready threads.
+ */
+ Chain_Control Ready;
+} Scheduler_simple_Control;
+
+/**
* @brief Initialize simple scheduler.
*
* This routine initializes the simple scheduler.
diff --git a/cpukit/score/include/rtems/score/schedulersimpleimpl.h b/cpukit/score/include/rtems/score/schedulersimpleimpl.h
index 25fbbc7..c51c6c3 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 8ea8b53..b825b29 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 67a2d51..134f6e8 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 7b8d338..841bcd1 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 );
}
--
1.7.7
More information about the devel
mailing list