[PATCH 09/12] scheduler: Add and use _Scheduler_default_Tick()

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Jun 12 15:12:35 UTC 2013


Delete _Scheduler_priority_Tick().  Use _Processors_Count for default
tick operation.  Delete _Scheduler_simple_smp_Tick().
---
 cpukit/score/Makefile.am                           |    4 +-
 cpukit/score/include/rtems/score/scheduler.h       |    8 ++
 cpukit/score/include/rtems/score/schedulercbs.h    |    2 +-
 cpukit/score/include/rtems/score/scheduleredf.h    |    2 +-
 .../score/include/rtems/score/schedulerpriority.h  |   11 +--
 cpukit/score/include/rtems/score/schedulersimple.h |    2 +-
 .../score/include/rtems/score/schedulersimplesmp.h |   11 +--
 cpukit/score/src/schedulerdefaulttick.c            |   92 +++++++++++++++++
 cpukit/score/src/schedulerprioritytick.c           |   83 ---------------
 cpukit/score/src/schedulersimplesmptick.c          |  107 --------------------
 10 files changed, 107 insertions(+), 215 deletions(-)
 create mode 100644 cpukit/score/src/schedulerdefaulttick.c
 delete mode 100644 cpukit/score/src/schedulerprioritytick.c
 delete mode 100644 cpukit/score/src/schedulersimplesmptick.c

diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 9bc40b1..dc018f0 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -138,7 +138,7 @@ endif
 if HAS_SMP
 libscore_a_SOURCES += src/isrsmp.c src/smp.c \
     src/schedulersimplesmpblock.c src/schedulersimplesmpschedule.c \
-    src/schedulersimplesmpunblock.c src/schedulersimplesmptick.c 
+    src/schedulersimplesmpunblock.c
 endif
 
 ## CORE_APIMUTEX_C_FILES
@@ -199,12 +199,12 @@ libscore_a_SOURCES += src/objectallocate.c src/objectclose.c \
 
 ## SCHEDULER_C_FILES
 libscore_a_SOURCES += src/scheduler.c
+libscore_a_SOURCES += src/schedulerdefaulttick.c
 libscore_a_SOURCES += src/schedulerdefaultstartidle.c
 
 ## SCHEDULERPRIORITY_C_FILES
 libscore_a_SOURCES += src/schedulerpriority.c \
     src/schedulerpriorityallocate.c \
-    src/schedulerprioritytick.c \
     src/schedulerpriorityblock.c \
     src/schedulerpriorityenqueue.c \
     src/schedulerpriorityenqueuefirst.c \
diff --git a/cpukit/score/include/rtems/score/scheduler.h b/cpukit/score/include/rtems/score/scheduler.h
index 930412f..6e3b35f 100644
--- a/cpukit/score/include/rtems/score/scheduler.h
+++ b/cpukit/score/include/rtems/score/scheduler.h
@@ -150,6 +150,14 @@ extern Scheduler_Control  _Scheduler;
 void _Scheduler_Handler_initialization( void );
 
 /**
+ * @brief Performs tick operations depending on the CPU budget algorithm for
+ * each executing thread.
+ *
+ * This routine is invoked as part of processing each clock tick.
+ */
+void _Scheduler_default_Tick( void );
+
+/**
  * @brief Unblocks the thread.
  *
  * @param[in/out] thread An idle thread.
diff --git a/cpukit/score/include/rtems/score/schedulercbs.h b/cpukit/score/include/rtems/score/schedulercbs.h
index 41f8ab0..bec989f 100644
--- a/cpukit/score/include/rtems/score/schedulercbs.h
+++ b/cpukit/score/include/rtems/score/schedulercbs.h
@@ -60,7 +60,7 @@ extern "C" {
     _Scheduler_EDF_Extract,          /* extract entry point */ \
     _Scheduler_EDF_Priority_compare, /* compares two priorities */ \
     _Scheduler_CBS_Release_job,      /* new period of task */ \
-    _Scheduler_priority_Tick,        /* tick entry point */ \
+    _Scheduler_default_Tick,         /* tick entry point */ \
     _Scheduler_default_Start_idle    /* start idle entry point */ \
   }
 
diff --git a/cpukit/score/include/rtems/score/scheduleredf.h b/cpukit/score/include/rtems/score/scheduleredf.h
index 7846067..090974b 100644
--- a/cpukit/score/include/rtems/score/scheduleredf.h
+++ b/cpukit/score/include/rtems/score/scheduleredf.h
@@ -53,7 +53,7 @@ extern "C" {
     _Scheduler_EDF_Extract,          /* extract entry point */ \
     _Scheduler_EDF_Priority_compare, /* compares two priorities */ \
     _Scheduler_EDF_Release_job,      /* new period of task */ \
-    _Scheduler_priority_Tick,        /* tick entry point */ \
+    _Scheduler_default_Tick,         /* tick entry point */ \
     _Scheduler_default_Start_idle    /* start idle entry point */ \
   }
 
diff --git a/cpukit/score/include/rtems/score/schedulerpriority.h b/cpukit/score/include/rtems/score/schedulerpriority.h
index f0582c1..f6fdaff 100644
--- a/cpukit/score/include/rtems/score/schedulerpriority.h
+++ b/cpukit/score/include/rtems/score/schedulerpriority.h
@@ -52,7 +52,7 @@ extern "C" {
     _Scheduler_priority_Extract,          /* extract entry point */ \
     _Scheduler_priority_Priority_compare, /* compares two priorities */ \
     _Scheduler_priority_Release_job,      /* new period of task */ \
-    _Scheduler_priority_Tick,             /* tick entry point */ \
+    _Scheduler_default_Tick,              /* tick entry point */ \
     _Scheduler_default_Start_idle         /* start idle entry point */ \
   }
 
@@ -226,15 +226,6 @@ void _Scheduler_priority_Release_job (
 );
 
 /**
- *  @brief Determines if the current thread allows timeslicing.
- *
- *  This routine is invoked as part of processing each clock tick.
- *  It is responsible for determining if the current thread allows
- *  timeslicing and, if so, when its timeslice expires.
- */
-void _Scheduler_priority_Tick( void );
-
-/**
  *  This is the major bit map.
  */
 extern volatile Priority_bit_map_Control _Priority_Major_bit_map;
diff --git a/cpukit/score/include/rtems/score/schedulersimple.h b/cpukit/score/include/rtems/score/schedulersimple.h
index 47b74be..0cdc8fc 100644
--- a/cpukit/score/include/rtems/score/schedulersimple.h
+++ b/cpukit/score/include/rtems/score/schedulersimple.h
@@ -50,7 +50,7 @@ extern "C" {
     _Scheduler_simple_Extract,            /* extract entry point */ \
     _Scheduler_priority_Priority_compare, /* compares two priorities */ \
     _Scheduler_priority_Release_job,      /* new period of task */ \
-    _Scheduler_priority_Tick,             /* tick entry point */ \
+    _Scheduler_default_Tick,              /* tick entry point */ \
     _Scheduler_default_Start_idle         /* start idle entry point */ \
   }
 
diff --git a/cpukit/score/include/rtems/score/schedulersimplesmp.h b/cpukit/score/include/rtems/score/schedulersimplesmp.h
index 63213c6..baac7b2 100644
--- a/cpukit/score/include/rtems/score/schedulersimplesmp.h
+++ b/cpukit/score/include/rtems/score/schedulersimplesmp.h
@@ -62,7 +62,7 @@ extern "C" {
     _Scheduler_simple_Extract,            /* extract entry point */ \
     _Scheduler_priority_Priority_compare, /* compares two priorities */ \
     _Scheduler_priority_Release_job,      /* new period of task */ \
-    _Scheduler_simple_smp_Tick            /* tick entry point */ \
+    _Scheduler_default_Tick               /* tick entry point */ \
   }
 
 /**
@@ -102,15 +102,6 @@ void _Scheduler_simple_smp_Unblock(
   Thread_Control *the_thread
 );
 
-/**
- *  @brief Invoked as part of processing each SMP clock tick.
- *
- *  This routine is invoked as part of processing each clock tick.
- *  It is responsible for determining if the current thread allows
- *  timeslicing and, if so, when its timeslice expires.
- */
-void _Scheduler_simple_smp_Tick( void );
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/cpukit/score/src/schedulerdefaulttick.c b/cpukit/score/src/schedulerdefaulttick.c
new file mode 100644
index 0000000..a291edc
--- /dev/null
+++ b/cpukit/score/src/schedulerdefaulttick.c
@@ -0,0 +1,92 @@
+/**
+ * @file
+ *
+ * @brief Priority Scheduler At Tick Handler
+ *
+ * @ingroup ScoreScheduler
+ */
+
+/*
+ *  COPYRIGHT (c) 1989-2009.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/score/scheduler.h>
+#include <rtems/score/thread.h>
+
+static void _Scheduler_default_Tick_for_executing( Thread_Control *executing )
+{
+  #ifdef __RTEMS_USE_TICKS_FOR_STATISTICS__
+    /*
+     *  Increment the number of ticks this thread has been executing
+     */
+    executing->cpu_time_used++;
+  #endif
+
+  /*
+   *  If the thread is not preemptible or is not ready, then
+   *  just return.
+   */
+
+  if ( !executing->is_preemptible )
+    return;
+
+  if ( !_States_Is_ready( executing->current_state ) )
+    return;
+
+  /*
+   *  The cpu budget algorithm determines what happens next.
+   */
+
+  switch ( executing->budget_algorithm ) {
+    case THREAD_CPU_BUDGET_ALGORITHM_NONE:
+      break;
+
+    case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE:
+    #if defined(RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE)
+      case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE:
+    #endif
+      if ( (int)(--executing->cpu_time_budget) <= 0 ) {
+
+        /*
+         *  A yield performs the ready chain mechanics needed when
+         *  resetting a timeslice.  If no other thread's are ready
+         *  at the priority of the currently executing thread, then the
+         *  executing thread's timeslice is reset.  Otherwise, the
+         *  currently executing thread is placed at the rear of the
+         *  FIFO for this priority and a new heir is selected.
+         */
+        _Scheduler_Yield_with_thread( executing );
+        executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
+      }
+      break;
+
+    #if defined(RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT)
+      case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT:
+	if ( --executing->cpu_time_budget == 0 )
+	  (*executing->budget_callout)( executing );
+	break;
+    #endif
+  }
+}
+
+void _Scheduler_default_Tick( void )
+{
+  uint32_t processor_count = _Processors_Count;
+  uint32_t processor;
+
+  for ( processor = 0 ; processor < processor_count ; ++processor ) {
+    _Scheduler_default_Tick_for_executing(
+      _Per_CPU_Information[ processor ].executing
+    );
+  }
+}
diff --git a/cpukit/score/src/schedulerprioritytick.c b/cpukit/score/src/schedulerprioritytick.c
deleted file mode 100644
index 8fa739c..0000000
--- a/cpukit/score/src/schedulerprioritytick.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * @file
- *
- * @brief Priority Scheduler At Tick Handler
- *
- * @ingroup ScoreScheduler
- */
-
-/*
- *  COPYRIGHT (c) 1989-2009.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.com/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rtems/system.h>
-#include <rtems/score/schedulerpriority.h>
-
-void _Scheduler_priority_Tick( void )
-{
-  Thread_Control *executing;
-
-  executing = _Thread_Executing;
-
-  #ifdef __RTEMS_USE_TICKS_FOR_STATISTICS__
-    /*
-     *  Increment the number of ticks this thread has been executing
-     */
-    executing->cpu_time_used++;
-  #endif
-
-  /*
-   *  If the thread is not preemptible or is not ready, then
-   *  just return.
-   */
-
-  if ( !executing->is_preemptible )
-    return;
-
-  if ( !_States_Is_ready( executing->current_state ) )
-    return;
-
-  /*
-   *  The cpu budget algorithm determines what happens next.
-   */
-
-  switch ( executing->budget_algorithm ) {
-    case THREAD_CPU_BUDGET_ALGORITHM_NONE:
-      break;
-
-    case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE:
-    #if defined(RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE)
-      case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE:
-    #endif
-      if ( (int)(--executing->cpu_time_budget) <= 0 ) {
-
-        /*
-         *  A yield performs the ready chain mechanics needed when
-         *  resetting a timeslice.  If no other thread's are ready
-         *  at the priority of the currently executing thread, then the
-         *  executing thread's timeslice is reset.  Otherwise, the
-         *  currently executing thread is placed at the rear of the
-         *  FIFO for this priority and a new heir is selected.
-         */
-        _Scheduler_Yield_with_thread( executing );
-        executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
-      }
-      break;
-
-    #if defined(RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT)
-      case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT:
-	if ( --executing->cpu_time_budget == 0 )
-	  (*executing->budget_callout)( executing );
-	break;
-    #endif
-  }
-}
diff --git a/cpukit/score/src/schedulersimplesmptick.c b/cpukit/score/src/schedulersimplesmptick.c
deleted file mode 100644
index 72f8b1f..0000000
--- a/cpukit/score/src/schedulersimplesmptick.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- *  @file
- *
- *  @brief Scheduler Simple SMP Tick Method
- *  @ingroup ScoreScheduler
- */
-
-/*
- *  COPYRIGHT (c) 1989-2009.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.com/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rtems/system.h>
-#include <rtems/score/schedulersimplesmp.h>
-#include <rtems/score/smp.h>
-
-static void _Scheduler_simple_smp_Tick_helper(
-  int cpu
-)
-{
-  Thread_Control *executing;
-  ISR_Level       level;
-
-  executing = _Per_CPU_Information[cpu].executing;
-
-  #ifdef __RTEMS_USE_TICKS_FOR_STATISTICS__
-    /*
-     *  Increment the number of ticks this thread has been executing
-     */
-    executing->cpu_time_used++;
-  #endif
-
-  /*
-   *  If the thread is not preemptible or is not ready, then
-   *  just return.
-   */
-
-  if ( !executing->is_preemptible )
-    return;
-
-  if ( !_States_Is_ready( executing->current_state ) )
-    return;
-
-  /*
-   *  The cpu budget algorithm determines what happens next.
-   */
-
-  switch ( executing->budget_algorithm ) {
-    case THREAD_CPU_BUDGET_ALGORITHM_NONE:
-      break;
-
-    case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE:
-    #if defined(RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE)
-      case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE:
-    #endif
-      if ( (int)(--executing->cpu_time_budget) <= 0 ) {
-
-        /*
-         *  A yield performs the ready chain mechanics needed when
-         *  resetting a timeslice.  If no other thread's are ready
-         *  at the priority of the currently executing thread, then the
-         *  executing thread's timeslice is reset.  Otherwise, the
-         *  currently executing thread is placed at the rear of the
-         *  FIFO for this priority and a new heir is selected.
-         *
-         *  In the SMP case, we do the chain manipulation for every
-         *  CPU, then schedule after all CPUs have been evaluated.
-         */
-        _ISR_Disable( level );
-          _Scheduler_simple_Ready_queue_requeue( &_Scheduler, executing );
-        _ISR_Enable( level );
-
-        executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
-      }
-      break;
-
-    #if defined(RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT)
-      case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT:
-	if ( --executing->cpu_time_budget == 0 )
-	  (*executing->budget_callout)( executing );
-	break;
-    #endif
-  }
-}
-
-void _Scheduler_simple_smp_Tick( void )
-{
-  uint32_t        cpu;
-
-  /*
-   *  Iterate over all cores, updating time slicing information
-   *  and logically performing a yield.  Then perform a schedule
-   *  operation to account for all the changes.
-   */
-  for ( cpu=0 ; cpu < _SMP_Processor_count ; cpu++ ) {
-    _Scheduler_simple_smp_Tick_helper( cpu );
-  }
-  _Scheduler_simple_smp_Schedule();
-}
-- 
1.7.7




More information about the devel mailing list