Changeset 0104056 in rtems


Ignore:
Timestamp:
Dec 3, 2014, 10:14:42 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
8905201
Parents:
f54e503
git-author:
Sebastian Huber <sebastian.huber@…> (12/03/14 10:14:42)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/03/14 10:19:53)
Message:

sptests: Add get_one_tick_busy_value()

Extract this function from
interrupt_critical_section_test_support_initialize().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/spintrcritical_support/intrcritical.c

    rf54e503 r0104056  
    6868}
    6969
     70static rtems_interval get_one_tick_busy_value( void )
     71{
     72  rtems_interval last;
     73  rtems_interval now;
     74  rtems_interval a;
     75  rtems_interval b;
     76  rtems_interval m;
     77
     78  /* Choose a lower bound */
     79  a = 1;
     80
     81  /* Estimate an upper bound */
     82
     83  wait_for_tick_change();
     84  b = 2 * estimate_busy_loop_maximum();
     85
     86  while ( true ) {
     87    last = wait_for_tick_change();
     88    busy( b );
     89    now = rtems_clock_get_ticks_since_boot();
     90
     91    if ( now != last ) {
     92      break;
     93    }
     94
     95    b *= 2;
     96    last = now;
     97  }
     98
     99  /* Find a good value */
     100  do {
     101    m = ( a + b ) / 2;
     102
     103    last = wait_for_tick_change();
     104    busy( m );
     105    now = rtems_clock_get_ticks_since_boot();
     106
     107    if ( now != last ) {
     108      b = m;
     109    } else {
     110      a = m;
     111    }
     112  } while ( b - a > 1 );
     113
     114  return m;
     115}
     116
    70117static bool interrupt_critical_busy_wait( void )
    71118{
     
    88135)
    89136{
    90   rtems_interval last;
    91   rtems_interval now;
    92   rtems_interval a;
    93   rtems_interval b;
    94137  rtems_interval m;
    95138
     
    104147  }
    105148
    106   /* Choose a lower bound */
    107   a = 1;
    108 
    109   /* Estimate an upper bound */
    110 
    111   wait_for_tick_change();
    112   b = 2 * estimate_busy_loop_maximum();
    113 
    114   while ( true ) {
    115     last = wait_for_tick_change();
    116     busy( b );
    117     now = rtems_clock_get_ticks_since_boot();
    118 
    119     if ( now != last ) {
    120       break;
    121     }
    122 
    123     b *= 2;
    124     last = now;
    125   }
    126 
    127   /* Find a good value */
    128   do {
    129     m = ( a + b ) / 2;
    130 
    131     last = wait_for_tick_change();
    132     busy( m );
    133     now = rtems_clock_get_ticks_since_boot();
    134 
    135     if ( now != last ) {
    136       b = m;
    137     } else {
    138       a = m;
    139     }
    140   } while ( b - a > 1 );
     149  m = get_one_tick_busy_value();
    141150
    142151  interrupt_critical.minimum = 0;
Note: See TracChangeset for help on using the changeset viewer.