[rtems commit] score: _Scheduler_priority_Ready_queue_initialize

Sebastian Huber sebh at rtems.org
Tue Jun 14 10:10:08 UTC 2016


Module:    rtems
Branch:    master
Commit:    042072bfdfa6ff6a54c74cc54476c5175377bf63
Changeset: http://git.rtems.org/rtems/commit/?id=042072bfdfa6ff6a54c74cc54476c5175377bf63

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Jun 14 10:12:34 2016 +0200

score: _Scheduler_priority_Ready_queue_initialize

Use priority maximum of scheduler instance.  This avoids a potential
memory corruption on SMP configurations.

---

 cpukit/score/include/rtems/score/schedulerpriorityimpl.h | 9 +++++----
 cpukit/score/src/schedulerpriority.c                     | 5 ++++-
 cpukit/score/src/schedulerprioritysmp.c                  | 5 ++++-
 cpukit/score/src/schedulerstrongapa.c                    | 5 ++++-
 4 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/cpukit/score/include/rtems/score/schedulerpriorityimpl.h b/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
index ab5abdc..a18840f 100644
--- a/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerpriorityimpl.h
@@ -54,14 +54,15 @@ RTEMS_INLINE_ROUTINE Scheduler_priority_Node *_Scheduler_priority_Thread_get_nod
  * This routine initializes @a ready_queues for priority-based scheduling.
  */
 RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize(
-  Chain_Control *ready_queues
+  Chain_Control    *ready_queues,
+  Priority_Control  maximum_priority
 )
 {
   size_t index;
 
-  /* initialize ready queue structures */
-  for( index=0; index <= PRIORITY_MAXIMUM; index++)
-    _Chain_Initialize_empty( &ready_queues[index] );
+  for ( index = 0 ; index <= (size_t) maximum_priority ; ++index ) {
+    _Chain_Initialize_empty( &ready_queues[ index ] );
+  }
 }
 
 /**
diff --git a/cpukit/score/src/schedulerpriority.c b/cpukit/score/src/schedulerpriority.c
index 6dc055a..61505a4 100644
--- a/cpukit/score/src/schedulerpriority.c
+++ b/cpukit/score/src/schedulerpriority.c
@@ -27,5 +27,8 @@ void _Scheduler_priority_Initialize( const Scheduler_Control *scheduler )
     _Scheduler_priority_Get_context( scheduler );
 
   _Priority_bit_map_Initialize( &context->Bit_map );
-  _Scheduler_priority_Ready_queue_initialize( &context->Ready[ 0 ] );
+  _Scheduler_priority_Ready_queue_initialize(
+    &context->Ready[ 0 ],
+    scheduler->maximum_priority
+  );
 }
diff --git a/cpukit/score/src/schedulerprioritysmp.c b/cpukit/score/src/schedulerprioritysmp.c
index c08799f..bd042d2 100644
--- a/cpukit/score/src/schedulerprioritysmp.c
+++ b/cpukit/score/src/schedulerprioritysmp.c
@@ -39,7 +39,10 @@ void _Scheduler_priority_SMP_Initialize( const Scheduler_Control *scheduler )
 
   _Scheduler_SMP_Initialize( &self->Base );
   _Priority_bit_map_Initialize( &self->Bit_map );
-  _Scheduler_priority_Ready_queue_initialize( &self->Ready[ 0 ] );
+  _Scheduler_priority_Ready_queue_initialize(
+    &self->Ready[ 0 ],
+    scheduler->maximum_priority
+  );
 }
 
 void _Scheduler_priority_SMP_Node_initialize(
diff --git a/cpukit/score/src/schedulerstrongapa.c b/cpukit/score/src/schedulerstrongapa.c
index 09efde9..dd44097 100644
--- a/cpukit/score/src/schedulerstrongapa.c
+++ b/cpukit/score/src/schedulerstrongapa.c
@@ -165,7 +165,10 @@ void _Scheduler_strong_APA_Initialize( const Scheduler_Control *scheduler )
 
   _Scheduler_SMP_Initialize( &self->Base );
   _Priority_bit_map_Initialize( &self->Bit_map );
-  _Scheduler_priority_Ready_queue_initialize( &self->Ready[ 0 ] );
+  _Scheduler_priority_Ready_queue_initialize(
+    &self->Ready[ 0 ],
+    scheduler->maximum_priority
+  );
 }
 
 void _Scheduler_strong_APA_Node_initialize(




More information about the vc mailing list