Changeset 894d01c in rtems


Ignore:
Timestamp:
Mar 29, 2002, 3:32:18 PM (18 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
88f3393
Parents:
5729f62
Message:

2001-03-29 Joel Sherrill <joel@…>

  • Per PR147 addressed problems when reseting and inserting a timer into a timer chain that did not honor time passage since the last time the timer server was scheduled and the new insertion.
  • include/rtems/rtems/timer.h, src/timerreset.c, src/timerserver.c, src/timerserverfireafter.c, src/timerserverfirewhen.c: Broke up the "reset server" routine into a set of very specific routines that allowed the server to be unscheduled, timer chains to be "synchronized" with the current time before inserting a new timer.
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/rtems/ChangeLog

    r5729f62 r894d01c  
     12001-03-29      Joel Sherrill <joel@OARcorp.com>
     2
     3        * Per PR147 addressed problems when reseting and inserting a timer
     4        into a timer chain that did not honor time passage since the last
     5        time the timer server was scheduled and the new insertion.
     6        * include/rtems/rtems/timer.h, src/timerreset.c, src/timerserver.c,
     7        src/timerserverfireafter.c, src/timerserverfirewhen.c: Broke up
     8        the "reset server" routine into a set of very specific routines
     9        that allowed the server to be unscheduled, timer chains to be
     10        "synchronized" with the current time before inserting a new timer.
     11
    1122002-03-27      Ralf Corsepius <corsepiu@faw.uni-ulm.de>
    213
  • c/src/exec/rtems/include/rtems/rtems/timer.h

    r5729f62 r894d01c  
    136136
    137137/*
    138  *  _Timer_Server_reset
    139  *
    140  *  DESCRIPTION:
    141  *
    142  *  This routine resets the timers which determine when the Timer Server
    143  *  will wake up next to service task-based timers.
    144  */
    145 
    146 typedef enum {
    147   TIMER_SERVER_RESET_TICKS,
    148   TIMER_SERVER_RESET_SECONDS
    149 } Timer_Server_reset_mode;
    150 
    151 void _Timer_Server_reset(
    152   Timer_Server_reset_mode  reset_mode
    153 );
    154 
    155 /*
    156138 *  rtems_timer_create
    157139 *
     
    340322);
    341323
     324/*
     325 *  Macros and routines that expose the mechanisms required to service
     326 *  the Timer Server timer.  These stop the timer, synchronize it with
     327 *  the current time, and restart it.
     328 */
     329
     330extern Watchdog_Control _Timer_Seconds_timer;
     331
     332#define _Timer_Server_stop_ticks_timer() \
     333      _Watchdog_Remove( &_Timer_Server->Timer )
     334
     335#define _Timer_Server_stop_seconds_timer() \
     336      _Watchdog_Remove( &_Timer_Seconds_timer );
     337
     338void _Timer_Server_process_ticks_chain(void);
     339void _Timer_Server_process_seconds_chain(void);
     340
     341#define _Timer_Server_reset_ticks_timer() \
     342   do { \
     343      if ( !_Chain_Is_empty( &_Timer_Ticks_chain ) ) { \
     344        _Watchdog_Insert_ticks( &_Timer_Server->Timer, \
     345           ((Watchdog_Control *)_Timer_Ticks_chain.first)->delta_interval ); \
     346      } \
     347   } while (0)
     348
     349#define _Timer_Server_reset_seconds_timer() \
     350   do { \
     351      if ( !_Chain_Is_empty( &_Timer_Seconds_chain ) ) { \
     352        _Watchdog_Insert_seconds( &_Timer_Seconds_timer, \
     353          ((Watchdog_Control *)_Timer_Seconds_chain.first)->delta_interval ); \
     354      } \
     355   } while (0)
     356
    342357#ifndef __RTEMS_APPLICATION__
    343358#include <rtems/rtems/timer.inl>
  • c/src/exec/rtems/src/timerreset.c

    r5729f62 r894d01c  
    5858          break;
    5959        case TIMER_INTERVAL_ON_TASK:
     60          _Timer_Server_stop_ticks_timer();
    6061          _Watchdog_Remove( &the_timer->Ticker );
     62          _Timer_Server_process_ticks_chain();
    6163          _Watchdog_Insert( &_Timer_Ticks_chain, &the_timer->Ticker );
     64          _Timer_Server_reset_ticks_timer();
    6265          break;
    6366        case TIMER_TIME_OF_DAY:
  • c/src/exec/rtems/src/timerserver.c

    r5729f62 r894d01c  
    5050 *  The timer used to control when the Timer Server wakes up to service
    5151 *  "when" timers.
    52  *
    53  *  NOTE: This should NOT be used outside this file.
    5452 */
    5553
    5654Watchdog_Control _Timer_Seconds_timer;
    57 
    58 /*
    59  *  prototypes for support routines to process the chains
    60  */
    61 
    62 void _Timer_Process_ticks_chain(void);
    63 void _Timer_Process_seconds_chain(void);
    6455
    6556/*PAGE
     
    9889
    9990      _Thread_Set_state( _Timer_Server, STATES_DELAYING );
    100       _Timer_Server_reset( TIMER_SERVER_RESET_TICKS );
    101       _Timer_Server_reset( TIMER_SERVER_RESET_SECONDS );
     91      _Timer_Server_reset_ticks_timer();
     92      _Timer_Server_reset_seconds_timer();
    10293    _Thread_Enable_dispatch();
    10394
     95    /*
     96     *  At this point, at least one of the timers this task relies
     97     *  upon has fired.  Stop them both while we process any outstanding
     98     *  timers.  Before we block, we will restart them.
     99     */
     100 
     101      _Timer_Server_stop_ticks_timer();
     102      _Timer_Server_stop_seconds_timer();
    104103
    105104    /*
     
    111110
    112111    _Thread_Disable_dispatch();
    113       _Timer_Process_ticks_chain();
    114       _Timer_Process_seconds_chain();
     112      _Timer_Server_process_ticks_chain();
     113      _Timer_Server_process_seconds_chain();
    115114  }
    116115}
     
    246245/*PAGE
    247246 *
    248  *  _Timer_Server_reset
    249  *
    250  *  This routine resets the timers which determine when the Timer Server
    251  *  will wake up next to service task-based timers.
    252  *
    253  *  Input parameters:
    254  *    do_ticks - TRUE indicates to process the ticks list
    255  *               FALSE indicates to process the seconds list
    256  *
    257  *  Output parameters:  NONE
    258  */
    259 
    260 void _Timer_Server_reset(
    261   Timer_Server_reset_mode reset_mode
    262 )
    263 {
    264   Watchdog_Interval  units;
    265 
    266   switch ( reset_mode ) {
    267     case TIMER_SERVER_RESET_TICKS:
    268       _Watchdog_Remove( &_Timer_Server->Timer );
    269       _Timer_Process_ticks_chain();
    270       if ( !_Chain_Is_empty( &_Timer_Ticks_chain ) ) {
    271         units = ((Watchdog_Control *)_Timer_Ticks_chain.first)->delta_interval;
    272         _Watchdog_Insert_ticks( &_Timer_Server->Timer, units );
    273       }
    274       break;
    275     case TIMER_SERVER_RESET_SECONDS:
    276       _Watchdog_Remove(  &_Timer_Seconds_timer );
    277       _Timer_Process_seconds_chain();
    278       if ( !_Chain_Is_empty( &_Timer_Seconds_chain ) ) {
    279         units = ((Watchdog_Control *)_Timer_Seconds_chain.first)->delta_interval;
    280         _Watchdog_Insert_seconds( &_Timer_Seconds_timer, units );
    281       }
    282       break;
    283   }
    284 }
    285 
    286 /*PAGE
    287  *
    288  *  _Timer_Server_Process_ticks_chain
     247 *  _Timer_Server_process_ticks_chain
    289248 *
    290249 *  This routine is responsible for adjusting the list of task-based
     
    296255 */
    297256
    298 void _Timer_Process_ticks_chain(void)
     257void _Timer_Server_process_ticks_chain(void)
    299258{
    300259  Watchdog_Interval snapshot;
     
    313272/*PAGE
    314273 *
    315  *  _Timer_Server_Process_seconds_chain
     274 *  _Timer_Server_process_seconds_chain
    316275 *
    317276 *  This routine is responsible for adjusting the list of task-based
     
    323282 */
    324283
    325 void _Timer_Process_seconds_chain(void)
     284void _Timer_Server_process_seconds_chain(void)
    326285{
    327286  Watchdog_Interval snapshot;
  • c/src/exec/rtems/src/timerserverfireafter.c

    r5729f62 r894d01c  
    7070      _Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data );
    7171      the_timer->Ticker.initial = ticks;
     72
     73      _Timer_Server_stop_ticks_timer();
     74      _Timer_Server_process_ticks_chain();
    7275      _Watchdog_Insert( &_Timer_Ticks_chain, &the_timer->Ticker );
    73       _Timer_Server_reset( TIMER_SERVER_RESET_TICKS );
     76       _Timer_Server_reset_ticks_timer();
     77
    7478      _Thread_Enable_dispatch();
    7579      return RTEMS_SUCCESSFUL;
  • c/src/exec/rtems/src/timerserverfirewhen.c

    r5729f62 r894d01c  
    7878      _Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data );
    7979      the_timer->Ticker.initial = seconds - _TOD_Seconds_since_epoch;
     80
     81      _Timer_Server_stop_seconds_timer();
     82      _Timer_Server_process_seconds_chain();
    8083      _Watchdog_Insert( &_Timer_Seconds_chain, &the_timer->Ticker );
    81       _Timer_Server_reset( TIMER_SERVER_RESET_SECONDS );
     84       _Timer_Server_reset_seconds_timer();
     85
    8286      _Thread_Enable_dispatch();
    8387      return RTEMS_SUCCESSFUL;
  • cpukit/rtems/ChangeLog

    r5729f62 r894d01c  
     12001-03-29      Joel Sherrill <joel@OARcorp.com>
     2
     3        * Per PR147 addressed problems when reseting and inserting a timer
     4        into a timer chain that did not honor time passage since the last
     5        time the timer server was scheduled and the new insertion.
     6        * include/rtems/rtems/timer.h, src/timerreset.c, src/timerserver.c,
     7        src/timerserverfireafter.c, src/timerserverfirewhen.c: Broke up
     8        the "reset server" routine into a set of very specific routines
     9        that allowed the server to be unscheduled, timer chains to be
     10        "synchronized" with the current time before inserting a new timer.
     11
    1122002-03-27      Ralf Corsepius <corsepiu@faw.uni-ulm.de>
    213
  • cpukit/rtems/include/rtems/rtems/timer.h

    r5729f62 r894d01c  
    136136
    137137/*
    138  *  _Timer_Server_reset
    139  *
    140  *  DESCRIPTION:
    141  *
    142  *  This routine resets the timers which determine when the Timer Server
    143  *  will wake up next to service task-based timers.
    144  */
    145 
    146 typedef enum {
    147   TIMER_SERVER_RESET_TICKS,
    148   TIMER_SERVER_RESET_SECONDS
    149 } Timer_Server_reset_mode;
    150 
    151 void _Timer_Server_reset(
    152   Timer_Server_reset_mode  reset_mode
    153 );
    154 
    155 /*
    156138 *  rtems_timer_create
    157139 *
     
    340322);
    341323
     324/*
     325 *  Macros and routines that expose the mechanisms required to service
     326 *  the Timer Server timer.  These stop the timer, synchronize it with
     327 *  the current time, and restart it.
     328 */
     329
     330extern Watchdog_Control _Timer_Seconds_timer;
     331
     332#define _Timer_Server_stop_ticks_timer() \
     333      _Watchdog_Remove( &_Timer_Server->Timer )
     334
     335#define _Timer_Server_stop_seconds_timer() \
     336      _Watchdog_Remove( &_Timer_Seconds_timer );
     337
     338void _Timer_Server_process_ticks_chain(void);
     339void _Timer_Server_process_seconds_chain(void);
     340
     341#define _Timer_Server_reset_ticks_timer() \
     342   do { \
     343      if ( !_Chain_Is_empty( &_Timer_Ticks_chain ) ) { \
     344        _Watchdog_Insert_ticks( &_Timer_Server->Timer, \
     345           ((Watchdog_Control *)_Timer_Ticks_chain.first)->delta_interval ); \
     346      } \
     347   } while (0)
     348
     349#define _Timer_Server_reset_seconds_timer() \
     350   do { \
     351      if ( !_Chain_Is_empty( &_Timer_Seconds_chain ) ) { \
     352        _Watchdog_Insert_seconds( &_Timer_Seconds_timer, \
     353          ((Watchdog_Control *)_Timer_Seconds_chain.first)->delta_interval ); \
     354      } \
     355   } while (0)
     356
    342357#ifndef __RTEMS_APPLICATION__
    343358#include <rtems/rtems/timer.inl>
  • cpukit/rtems/src/timerreset.c

    r5729f62 r894d01c  
    5858          break;
    5959        case TIMER_INTERVAL_ON_TASK:
     60          _Timer_Server_stop_ticks_timer();
    6061          _Watchdog_Remove( &the_timer->Ticker );
     62          _Timer_Server_process_ticks_chain();
    6163          _Watchdog_Insert( &_Timer_Ticks_chain, &the_timer->Ticker );
     64          _Timer_Server_reset_ticks_timer();
    6265          break;
    6366        case TIMER_TIME_OF_DAY:
  • cpukit/rtems/src/timerserver.c

    r5729f62 r894d01c  
    5050 *  The timer used to control when the Timer Server wakes up to service
    5151 *  "when" timers.
    52  *
    53  *  NOTE: This should NOT be used outside this file.
    5452 */
    5553
    5654Watchdog_Control _Timer_Seconds_timer;
    57 
    58 /*
    59  *  prototypes for support routines to process the chains
    60  */
    61 
    62 void _Timer_Process_ticks_chain(void);
    63 void _Timer_Process_seconds_chain(void);
    6455
    6556/*PAGE
     
    9889
    9990      _Thread_Set_state( _Timer_Server, STATES_DELAYING );
    100       _Timer_Server_reset( TIMER_SERVER_RESET_TICKS );
    101       _Timer_Server_reset( TIMER_SERVER_RESET_SECONDS );
     91      _Timer_Server_reset_ticks_timer();
     92      _Timer_Server_reset_seconds_timer();
    10293    _Thread_Enable_dispatch();
    10394
     95    /*
     96     *  At this point, at least one of the timers this task relies
     97     *  upon has fired.  Stop them both while we process any outstanding
     98     *  timers.  Before we block, we will restart them.
     99     */
     100 
     101      _Timer_Server_stop_ticks_timer();
     102      _Timer_Server_stop_seconds_timer();
    104103
    105104    /*
     
    111110
    112111    _Thread_Disable_dispatch();
    113       _Timer_Process_ticks_chain();
    114       _Timer_Process_seconds_chain();
     112      _Timer_Server_process_ticks_chain();
     113      _Timer_Server_process_seconds_chain();
    115114  }
    116115}
     
    246245/*PAGE
    247246 *
    248  *  _Timer_Server_reset
    249  *
    250  *  This routine resets the timers which determine when the Timer Server
    251  *  will wake up next to service task-based timers.
    252  *
    253  *  Input parameters:
    254  *    do_ticks - TRUE indicates to process the ticks list
    255  *               FALSE indicates to process the seconds list
    256  *
    257  *  Output parameters:  NONE
    258  */
    259 
    260 void _Timer_Server_reset(
    261   Timer_Server_reset_mode reset_mode
    262 )
    263 {
    264   Watchdog_Interval  units;
    265 
    266   switch ( reset_mode ) {
    267     case TIMER_SERVER_RESET_TICKS:
    268       _Watchdog_Remove( &_Timer_Server->Timer );
    269       _Timer_Process_ticks_chain();
    270       if ( !_Chain_Is_empty( &_Timer_Ticks_chain ) ) {
    271         units = ((Watchdog_Control *)_Timer_Ticks_chain.first)->delta_interval;
    272         _Watchdog_Insert_ticks( &_Timer_Server->Timer, units );
    273       }
    274       break;
    275     case TIMER_SERVER_RESET_SECONDS:
    276       _Watchdog_Remove(  &_Timer_Seconds_timer );
    277       _Timer_Process_seconds_chain();
    278       if ( !_Chain_Is_empty( &_Timer_Seconds_chain ) ) {
    279         units = ((Watchdog_Control *)_Timer_Seconds_chain.first)->delta_interval;
    280         _Watchdog_Insert_seconds( &_Timer_Seconds_timer, units );
    281       }
    282       break;
    283   }
    284 }
    285 
    286 /*PAGE
    287  *
    288  *  _Timer_Server_Process_ticks_chain
     247 *  _Timer_Server_process_ticks_chain
    289248 *
    290249 *  This routine is responsible for adjusting the list of task-based
     
    296255 */
    297256
    298 void _Timer_Process_ticks_chain(void)
     257void _Timer_Server_process_ticks_chain(void)
    299258{
    300259  Watchdog_Interval snapshot;
     
    313272/*PAGE
    314273 *
    315  *  _Timer_Server_Process_seconds_chain
     274 *  _Timer_Server_process_seconds_chain
    316275 *
    317276 *  This routine is responsible for adjusting the list of task-based
     
    323282 */
    324283
    325 void _Timer_Process_seconds_chain(void)
     284void _Timer_Server_process_seconds_chain(void)
    326285{
    327286  Watchdog_Interval snapshot;
  • cpukit/rtems/src/timerserverfireafter.c

    r5729f62 r894d01c  
    7070      _Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data );
    7171      the_timer->Ticker.initial = ticks;
     72
     73      _Timer_Server_stop_ticks_timer();
     74      _Timer_Server_process_ticks_chain();
    7275      _Watchdog_Insert( &_Timer_Ticks_chain, &the_timer->Ticker );
    73       _Timer_Server_reset( TIMER_SERVER_RESET_TICKS );
     76       _Timer_Server_reset_ticks_timer();
     77
    7478      _Thread_Enable_dispatch();
    7579      return RTEMS_SUCCESSFUL;
  • cpukit/rtems/src/timerserverfirewhen.c

    r5729f62 r894d01c  
    7878      _Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data );
    7979      the_timer->Ticker.initial = seconds - _TOD_Seconds_since_epoch;
     80
     81      _Timer_Server_stop_seconds_timer();
     82      _Timer_Server_process_seconds_chain();
    8083      _Watchdog_Insert( &_Timer_Seconds_chain, &the_timer->Ticker );
    81       _Timer_Server_reset( TIMER_SERVER_RESET_SECONDS );
     84       _Timer_Server_reset_seconds_timer();
     85
    8286      _Thread_Enable_dispatch();
    8387      return RTEMS_SUCCESSFUL;
Note: See TracChangeset for help on using the changeset viewer.