diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-09-08 19:22:49 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-09-08 19:22:49 +0000 |
commit | ad4137358b2130dc297d07d828690702a1d1ca50 (patch) | |
tree | 6221c4bfb19a3910d1891f6dc123a6fa1dfafab6 | |
parent | 2009-09-08 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff) | |
download | rtems-ad4137358b2130dc297d07d828690702a1d1ca50.tar.bz2 |
2009-09-07 Sebastian Huber <Sebastian.Huber@embedded-brains.de>
* spintrcritical_support/intrcritical.c: Fixed timing rountines.
-rw-r--r-- | testsuites/sptests/ChangeLog | 4 | ||||
-rw-r--r-- | testsuites/sptests/spintrcritical_support/intrcritical.c | 84 |
2 files changed, 44 insertions, 44 deletions
diff --git a/testsuites/sptests/ChangeLog b/testsuites/sptests/ChangeLog index ca14d79a0f..22116503ec 100644 --- a/testsuites/sptests/ChangeLog +++ b/testsuites/sptests/ChangeLog @@ -1,3 +1,7 @@ +2009-09-07 Sebastian Huber <Sebastian.Huber@embedded-brains.de> + + * spintrcritical_support/intrcritical.c: Fixed timing rountines. + 2009-09-04 Joel Sherrill <joel.sherrill@oarcorp.com> * spfatal01/spfatal01.scn, spfatal01/testcase.h, diff --git a/testsuites/sptests/spintrcritical_support/intrcritical.c b/testsuites/sptests/spintrcritical_support/intrcritical.c index 7d1d3ecb0c..003cc9ece2 100644 --- a/testsuites/sptests/spintrcritical_support/intrcritical.c +++ b/testsuites/sptests/spintrcritical_support/intrcritical.c @@ -17,15 +17,43 @@ static uint32_t Maximum_current; static rtems_id Timer; static rtems_timer_service_routine (*TSR)( rtems_id, void * ); +static uint32_t interrupt_critical_remaining_units_of_tick( void ) +{ + uint32_t units = 0; + rtems_interval initial = rtems_clock_get_ticks_since_boot(); + + while ( initial == rtems_clock_get_ticks_since_boot() ) { + ++units; + } + + return units; +} + +static bool interrupt_critical_busy_wait( void ) +{ + uint32_t max = Maximum_current; + uint32_t unit = 0; + rtems_interval initial = rtems_clock_get_ticks_since_boot(); + + while ( unit < max && initial == rtems_clock_get_ticks_since_boot() ) { + ++unit; + } + + if ( max > 0 ) { + Maximum_current = max - 1; + + return false; + } else { + Maximum_current = Maximum; + + return true; + } +} + void interrupt_critical_section_test_support_initialize( rtems_timer_service_routine (*tsr)( rtems_id, void * ) ) { - Watchdog_Interval initial; - uint32_t counter; - - initial = _Watchdog_Ticks_since_boot; - Timer = 0; TSR = tsr; if ( tsr ) { @@ -36,33 +64,20 @@ void interrupt_critical_section_test_support_initialize( directive_failed( rc, "rtems_timer_create" ); } - /* - * Wait for starting point - */ - for (counter=0 ; initial == _Watchdog_Ticks_since_boot ; counter++) - ; - - initial = _Watchdog_Ticks_since_boot; - /* - * Wait for ending point - */ - for (counter=0 ; initial == _Watchdog_Ticks_since_boot ; counter++) - ; + /* Wait for tick change */ + interrupt_critical_remaining_units_of_tick(); - Maximum = counter; - Maximum_current = counter; + /* Get units for a hole tick */ + Maximum = interrupt_critical_remaining_units_of_tick(); + Maximum_current = Maximum; #if 0 - printf( "%d 0x%08x counts\n", counter, counter ); + printf( "%d 0x%08x units\n", Maximum, Maximum ); #endif } bool interrupt_critical_section_test_support_delay(void) { - uint32_t counter; - Watchdog_Interval initial; - bool retval; - if (TSR) { rtems_status_code rc; @@ -70,24 +85,5 @@ bool interrupt_critical_section_test_support_delay(void) directive_failed( rc, "timer_fire_after failed" ); } - /* - * Count down - */ - if ( !Maximum_current ) { - Maximum_current = Maximum; - retval = true; - } else - retval = false; - - initial = _Watchdog_Ticks_since_boot; - for (counter=Maximum_current ; counter ; counter--) - if ( initial != _Watchdog_Ticks_since_boot ) - break; - - Maximum_current--; - - /* - * Return so the test can try to generate the condition - */ - return retval; + return interrupt_critical_busy_wait(); } |