forked from Imagelibrary/rtems
tests: Fix rtems_test_spin_until_next_tick()
This bug surfaced due to sporadic failures in sptimecounter02. Adjust rtems_test_spin_for_ticks() to include the partial tick in the argument value.
This commit is contained in:
@@ -65,6 +65,8 @@ static rtems_task Task(
|
|||||||
status = rtems_rate_monotonic_create( Task_name[ argument ], &RM_period );
|
status = rtems_rate_monotonic_create( Task_name[ argument ], &RM_period );
|
||||||
directive_failed( status, "rtems_rate_monotonic_create" );
|
directive_failed( status, "rtems_rate_monotonic_create" );
|
||||||
|
|
||||||
|
rtems_test_spin_until_next_tick();
|
||||||
|
|
||||||
while ( FOREVER ) {
|
while ( FOREVER ) {
|
||||||
status = rtems_rate_monotonic_period( RM_period, Periods[ argument ] );
|
status = rtems_rate_monotonic_period( RM_period, Periods[ argument ] );
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#define __TEST_SUPPORT_h
|
#define __TEST_SUPPORT_h
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <rtems.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -28,9 +29,10 @@ const char *Get_Too_Long_Name(void);
|
|||||||
const char *Get_Longest_Name(void);
|
const char *Get_Longest_Name(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Spin for specified number of ticks.
|
* Spin for specified number of ticks. The first tick we spin through is a
|
||||||
|
* partial one.
|
||||||
*/
|
*/
|
||||||
void rtems_test_spin_for_ticks(int ticks);
|
void rtems_test_spin_for_ticks(rtems_interval ticks);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Spin until the next clock tick
|
* Spin until the next clock tick
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
/*
|
/*
|
||||||
* Burn CPU for specified number of ticks
|
* Burn CPU for specified number of ticks
|
||||||
*/
|
*/
|
||||||
void rtems_test_spin_for_ticks(int ticks)
|
void rtems_test_spin_for_ticks(rtems_interval ticks)
|
||||||
{
|
{
|
||||||
rtems_interval start;
|
rtems_interval start;
|
||||||
rtems_interval now;
|
rtems_interval now;
|
||||||
@@ -25,13 +25,7 @@ void rtems_test_spin_for_ticks(int ticks)
|
|||||||
start = rtems_clock_get_ticks_since_boot();
|
start = rtems_clock_get_ticks_since_boot();
|
||||||
do {
|
do {
|
||||||
now = rtems_clock_get_ticks_since_boot();
|
now = rtems_clock_get_ticks_since_boot();
|
||||||
/*
|
} while ( now - start < ticks );
|
||||||
* Spin for <= ticks so we spin >= number of ticks.
|
|
||||||
* The first tick we spin through is a partial one.
|
|
||||||
* So you sping "ticks" number of ticks plus a partial
|
|
||||||
* one.
|
|
||||||
*/
|
|
||||||
} while ( (now-start) <= ticks );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -45,5 +39,5 @@ void rtems_test_spin_until_next_tick( void )
|
|||||||
start = rtems_clock_get_ticks_since_boot();
|
start = rtems_clock_get_ticks_since_boot();
|
||||||
do {
|
do {
|
||||||
now = rtems_clock_get_ticks_since_boot();
|
now = rtems_clock_get_ticks_since_boot();
|
||||||
} while ( now != start );
|
} while ( now == start );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user