[rtems commit] sptests: Add get_one_tick_busy_value()

Sebastian Huber sebh at rtems.org
Wed Dec 3 10:20:32 UTC 2014


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Dec  3 11:14:42 2014 +0100

sptests: Add get_one_tick_busy_value()

Extract this function from
interrupt_critical_section_test_support_initialize().

---

 .../sptests/spintrcritical_support/intrcritical.c  | 67 ++++++++++++----------
 1 file changed, 38 insertions(+), 29 deletions(-)

diff --git a/testsuites/sptests/spintrcritical_support/intrcritical.c b/testsuites/sptests/spintrcritical_support/intrcritical.c
index dec308f..7cea9ad 100644
--- a/testsuites/sptests/spintrcritical_support/intrcritical.c
+++ b/testsuites/sptests/spintrcritical_support/intrcritical.c
@@ -67,25 +67,7 @@ static __attribute__( ( noinline ) ) void busy( rtems_interval max )
   } while ( i < max );
 }
 
-static bool interrupt_critical_busy_wait( void )
-{
-  rtems_interval max = interrupt_critical.maximum_current;
-  bool reset = max <= interrupt_critical.minimum;
-
-  if ( reset ) {
-    interrupt_critical.maximum_current = interrupt_critical.maximum;
-  } else {
-    interrupt_critical.maximum_current = max - 1;
-  }
-
-  busy( max );
-
-  return reset;
-}
-
-void interrupt_critical_section_test_support_initialize(
-  rtems_timer_service_routine_entry tsr
-)
+static rtems_interval get_one_tick_busy_value( void )
 {
   rtems_interval last;
   rtems_interval now;
@@ -93,16 +75,6 @@ void interrupt_critical_section_test_support_initialize(
   rtems_interval b;
   rtems_interval m;
 
-  interrupt_critical.tsr = tsr;
-
-  if ( tsr != NULL && interrupt_critical.timer == 0 ) {
-    rtems_status_code sc = rtems_timer_create(
-      INTERRUPT_CRITICAL_NAME,
-      &interrupt_critical.timer
-    );
-    rtems_test_assert( sc == RTEMS_SUCCESSFUL );
-  }
-
   /* Choose a lower bound */
   a = 1;
 
@@ -139,6 +111,43 @@ void interrupt_critical_section_test_support_initialize(
     }
   } while ( b - a > 1 );
 
+  return m;
+}
+
+static bool interrupt_critical_busy_wait( void )
+{
+  rtems_interval max = interrupt_critical.maximum_current;
+  bool reset = max <= interrupt_critical.minimum;
+
+  if ( reset ) {
+    interrupt_critical.maximum_current = interrupt_critical.maximum;
+  } else {
+    interrupt_critical.maximum_current = max - 1;
+  }
+
+  busy( max );
+
+  return reset;
+}
+
+void interrupt_critical_section_test_support_initialize(
+  rtems_timer_service_routine_entry tsr
+)
+{
+  rtems_interval m;
+
+  interrupt_critical.tsr = tsr;
+
+  if ( tsr != NULL && interrupt_critical.timer == 0 ) {
+    rtems_status_code sc = rtems_timer_create(
+      INTERRUPT_CRITICAL_NAME,
+      &interrupt_critical.timer
+    );
+    rtems_test_assert( sc == RTEMS_SUCCESSFUL );
+  }
+
+  m = get_one_tick_busy_value();
+
   interrupt_critical.minimum = 0;
   interrupt_critical.maximum = m;
   interrupt_critical.maximum_current = m;



More information about the vc mailing list