Changeset 422289e in rtems


Ignore:
Timestamp:
Jan 29, 2002, 6:18:14 PM (19 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
a94c2fbb
Parents:
49d0704
Message:

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

  • Fixed bug where resetting a timer that was not at the head of one of the task timer chains resulted in the Timer Server task waking up too far in the future.
  • Added rtems_timer_get_information() directive to support testing.
  • src/timerserver.c, include/rtems/rtems/timer.h,
  • src/timergetinfo.c: New file.
  • src/Makefile.am: Modified to reflect above.
Files:
2 added
6 edited

Legend:

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

    r49d0704 r422289e  
     12001-01-29      Joel Sherrill <joel@OARcorp.com>
     2
     3        * Fixed bug where resetting a timer that was not at the head
     4        of one of the task timer chains resulted in the Timer Server
     5        task waking up too far in the future.
     6        * Added rtems_timer_get_information() directive to support testing.
     7        * src/timerserver.c, include/rtems/rtems/timer.h,
     8        * src/timergetinfo.c: New file.
     9        * src/Makefile.am: Modified to reflect above.
     10
    1112001-01-22      Joel Sherrill <joel@OARcorp.com>
    212
  • c/src/exec/rtems/src/Makefile.am

    r49d0704 r422289e  
    2727
    2828TIMER_C_FILES = rtemstimer.c timercancel.c timercreate.c timerdelete.c \
    29     timerfireafter.c timerfirewhen.c timerident.c timerreset.c timerserver.c \
    30     timerserverfireafter.c timerserverfirewhen.c
     29    timerfireafter.c timerfirewhen.c timergetinfo.c timerident.c timerreset.c \
     30    timerserver.c timerserverfireafter.c timerserverfirewhen.c
    3131
    3232MESSAGE_QUEUE_C_FILES = msg.c msgqallocate.c msgqbroadcast.c msgqcreate.c \
  • c/src/exec/rtems/src/timerserver.c

    r49d0704 r422289e  
    4040
    4141/*
     42 *  These variables keep track of the last time the Timer Server actually
     43 *  processed the chain.
     44 */
     45
     46Watchdog_Interval _Timer_Server_seconds_last_time;
     47Watchdog_Interval _Timer_Server_ticks_last_time;
     48
     49/*
    4250 *  The timer used to control when the Timer Server wakes up to service
    4351 *  "when" timers.
     
    4755
    4856Watchdog_Control _Timer_Seconds_timer;
     57
     58/*
     59 *  prototypes for support routines to process the chains
     60 */
     61
     62void _Timer_Process_ticks_chain(void);
     63void _Timer_Process_seconds_chain(void);
    4964
    5065/*PAGE
     
    6782)
    6883{
    69   Watchdog_Interval snapshot;
    70   Watchdog_Interval ticks_last_time;
    71   Watchdog_Interval seconds_last_time;
    72   Watchdog_Interval ticks;
    73 
    7484  /*
    7585   *  Initialize the "last time" markers to indicate the timer that
     
    7787   */
    7888
    79   ticks_last_time   = _Watchdog_Ticks_since_boot;
    80   seconds_last_time = _TOD_Seconds_since_epoch;
     89  _Timer_Server_ticks_last_time   = _Watchdog_Ticks_since_boot;
     90  _Timer_Server_seconds_last_time = _TOD_Seconds_since_epoch;
    8191
    8292  _Thread_Disable_dispatch();
     
    101111
    102112    _Thread_Disable_dispatch();
    103 
    104     /*
    105      *  Process the ticks chain
    106      */
    107 
    108     snapshot = _Watchdog_Ticks_since_boot;
    109     ticks = snapshot - ticks_last_time;
    110     ticks_last_time = snapshot;
    111     _Watchdog_Adjust( &_Timer_Ticks_chain, WATCHDOG_FORWARD, ticks );
    112 
    113     /*
    114      *  Process the seconds chain.  Start by checking that the Time
    115      *  of Day (TOD) has not been set backwards.  If it has then
    116      *  we want to adjust the _Timer_Seconds_chain to indicate this.
    117      */
    118 
    119     snapshot =  _TOD_Seconds_since_epoch;
    120     if ( snapshot > seconds_last_time ) {
    121       /*
    122        *  This path is for normal forward movement and cases where the
    123        *  TOD has been set forward.
    124        */
    125 
    126       ticks = snapshot - seconds_last_time;
    127       _Watchdog_Adjust( &_Timer_Seconds_chain, WATCHDOG_FORWARD, ticks );
    128 
    129     } else if ( snapshot < seconds_last_time ) {
    130        /*
    131         *  The current TOD is before the last TOD which indicates that
    132         *  TOD has been set backwards.
    133         */
    134 
    135        ticks = seconds_last_time - snapshot;
    136        _Watchdog_Adjust( &_Timer_Seconds_chain, WATCHDOG_BACKWARD, ticks );
    137     }
    138     seconds_last_time = snapshot;
     113      _Timer_Process_ticks_chain();
     114      _Timer_Process_seconds_chain();
    139115  }
    140116}
     
    290266  switch ( reset_mode ) {
    291267    case TIMER_SERVER_RESET_TICKS:
    292       _Watchdog_Remove(  &_Timer_Server->Timer );
    293       units = ((Watchdog_Control *)_Timer_Ticks_chain.first)->delta_interval;
    294       _Watchdog_Insert_ticks( &_Timer_Server->Timer, units );
     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      }
    295274      break;
    296275    case TIMER_SERVER_RESET_SECONDS:
    297276      _Watchdog_Remove(  &_Timer_Seconds_timer );
    298       units = ((Watchdog_Control *)_Timer_Seconds_chain.first)->delta_interval;
    299       _Watchdog_Insert_seconds( &_Timer_Seconds_timer, units );
     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      }
    300282      break;
    301283  }
    302284}
    303285
     286/*PAGE
     287 *
     288 *  _Timer_Server_Process_ticks_chain
     289 *
     290 *  This routine is responsible for adjusting the list of task-based
     291 *  interval timers to reflect the passage of time.
     292 *
     293 *  Input parameters:   NONE
     294 *
     295 *  Output parameters:  NONE
     296 */
     297
     298void _Timer_Process_ticks_chain(void)
     299{
     300  Watchdog_Interval snapshot;
     301  Watchdog_Interval ticks;
     302
     303  snapshot = _Watchdog_Ticks_since_boot;
     304  if ( snapshot >= _Timer_Server_ticks_last_time )
     305     ticks = snapshot - _Timer_Server_ticks_last_time;
     306  else
     307     ticks = (0xFFFFFFFF - _Timer_Server_ticks_last_time) + snapshot;
     308 
     309  _Timer_Server_ticks_last_time = snapshot;
     310  _Watchdog_Adjust( &_Timer_Ticks_chain, WATCHDOG_FORWARD, ticks );
     311}
     312
     313/*PAGE
     314 *
     315 *  _Timer_Server_Process_seconds_chain
     316 *
     317 *  This routine is responsible for adjusting the list of task-based
     318 *  time of day timers to reflect the passage of time.
     319 *
     320 *  Input parameters:   NONE
     321 *
     322 *  Output parameters:  NONE
     323 */
     324
     325void _Timer_Process_seconds_chain(void)
     326{
     327  Watchdog_Interval snapshot;
     328  Watchdog_Interval ticks;
     329
     330  /*
     331   *  Process the seconds chain.  Start by checking that the Time
     332   *  of Day (TOD) has not been set backwards.  If it has then
     333   *  we want to adjust the _Timer_Seconds_chain to indicate this.
     334   */
     335
     336  snapshot =  _TOD_Seconds_since_epoch;
     337  if ( snapshot > _Timer_Server_seconds_last_time ) {
     338    /*
     339     *  This path is for normal forward movement and cases where the
     340     *  TOD has been set forward.
     341     */
     342
     343    ticks = snapshot - _Timer_Server_seconds_last_time;
     344    _Watchdog_Adjust( &_Timer_Seconds_chain, WATCHDOG_FORWARD, ticks );
     345
     346  } else if ( snapshot < _Timer_Server_seconds_last_time ) {
     347     /*
     348      *  The current TOD is before the last TOD which indicates that
     349      *  TOD has been set backwards.
     350      */
     351
     352     ticks = _Timer_Server_seconds_last_time - snapshot;
     353     _Watchdog_Adjust( &_Timer_Seconds_chain, WATCHDOG_BACKWARD, ticks );
     354  }
     355  _Timer_Server_seconds_last_time = snapshot;
     356}
     357
  • cpukit/rtems/ChangeLog

    r49d0704 r422289e  
     12001-01-29      Joel Sherrill <joel@OARcorp.com>
     2
     3        * Fixed bug where resetting a timer that was not at the head
     4        of one of the task timer chains resulted in the Timer Server
     5        task waking up too far in the future.
     6        * Added rtems_timer_get_information() directive to support testing.
     7        * src/timerserver.c, include/rtems/rtems/timer.h,
     8        * src/timergetinfo.c: New file.
     9        * src/Makefile.am: Modified to reflect above.
     10
    1112001-01-22      Joel Sherrill <joel@OARcorp.com>
    212
  • cpukit/rtems/src/Makefile.am

    r49d0704 r422289e  
    2727
    2828TIMER_C_FILES = rtemstimer.c timercancel.c timercreate.c timerdelete.c \
    29     timerfireafter.c timerfirewhen.c timerident.c timerreset.c timerserver.c \
    30     timerserverfireafter.c timerserverfirewhen.c
     29    timerfireafter.c timerfirewhen.c timergetinfo.c timerident.c timerreset.c \
     30    timerserver.c timerserverfireafter.c timerserverfirewhen.c
    3131
    3232MESSAGE_QUEUE_C_FILES = msg.c msgqallocate.c msgqbroadcast.c msgqcreate.c \
  • cpukit/rtems/src/timerserver.c

    r49d0704 r422289e  
    4040
    4141/*
     42 *  These variables keep track of the last time the Timer Server actually
     43 *  processed the chain.
     44 */
     45
     46Watchdog_Interval _Timer_Server_seconds_last_time;
     47Watchdog_Interval _Timer_Server_ticks_last_time;
     48
     49/*
    4250 *  The timer used to control when the Timer Server wakes up to service
    4351 *  "when" timers.
     
    4755
    4856Watchdog_Control _Timer_Seconds_timer;
     57
     58/*
     59 *  prototypes for support routines to process the chains
     60 */
     61
     62void _Timer_Process_ticks_chain(void);
     63void _Timer_Process_seconds_chain(void);
    4964
    5065/*PAGE
     
    6782)
    6883{
    69   Watchdog_Interval snapshot;
    70   Watchdog_Interval ticks_last_time;
    71   Watchdog_Interval seconds_last_time;
    72   Watchdog_Interval ticks;
    73 
    7484  /*
    7585   *  Initialize the "last time" markers to indicate the timer that
     
    7787   */
    7888
    79   ticks_last_time   = _Watchdog_Ticks_since_boot;
    80   seconds_last_time = _TOD_Seconds_since_epoch;
     89  _Timer_Server_ticks_last_time   = _Watchdog_Ticks_since_boot;
     90  _Timer_Server_seconds_last_time = _TOD_Seconds_since_epoch;
    8191
    8292  _Thread_Disable_dispatch();
     
    101111
    102112    _Thread_Disable_dispatch();
    103 
    104     /*
    105      *  Process the ticks chain
    106      */
    107 
    108     snapshot = _Watchdog_Ticks_since_boot;
    109     ticks = snapshot - ticks_last_time;
    110     ticks_last_time = snapshot;
    111     _Watchdog_Adjust( &_Timer_Ticks_chain, WATCHDOG_FORWARD, ticks );
    112 
    113     /*
    114      *  Process the seconds chain.  Start by checking that the Time
    115      *  of Day (TOD) has not been set backwards.  If it has then
    116      *  we want to adjust the _Timer_Seconds_chain to indicate this.
    117      */
    118 
    119     snapshot =  _TOD_Seconds_since_epoch;
    120     if ( snapshot > seconds_last_time ) {
    121       /*
    122        *  This path is for normal forward movement and cases where the
    123        *  TOD has been set forward.
    124        */
    125 
    126       ticks = snapshot - seconds_last_time;
    127       _Watchdog_Adjust( &_Timer_Seconds_chain, WATCHDOG_FORWARD, ticks );
    128 
    129     } else if ( snapshot < seconds_last_time ) {
    130        /*
    131         *  The current TOD is before the last TOD which indicates that
    132         *  TOD has been set backwards.
    133         */
    134 
    135        ticks = seconds_last_time - snapshot;
    136        _Watchdog_Adjust( &_Timer_Seconds_chain, WATCHDOG_BACKWARD, ticks );
    137     }
    138     seconds_last_time = snapshot;
     113      _Timer_Process_ticks_chain();
     114      _Timer_Process_seconds_chain();
    139115  }
    140116}
     
    290266  switch ( reset_mode ) {
    291267    case TIMER_SERVER_RESET_TICKS:
    292       _Watchdog_Remove(  &_Timer_Server->Timer );
    293       units = ((Watchdog_Control *)_Timer_Ticks_chain.first)->delta_interval;
    294       _Watchdog_Insert_ticks( &_Timer_Server->Timer, units );
     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      }
    295274      break;
    296275    case TIMER_SERVER_RESET_SECONDS:
    297276      _Watchdog_Remove(  &_Timer_Seconds_timer );
    298       units = ((Watchdog_Control *)_Timer_Seconds_chain.first)->delta_interval;
    299       _Watchdog_Insert_seconds( &_Timer_Seconds_timer, units );
     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      }
    300282      break;
    301283  }
    302284}
    303285
     286/*PAGE
     287 *
     288 *  _Timer_Server_Process_ticks_chain
     289 *
     290 *  This routine is responsible for adjusting the list of task-based
     291 *  interval timers to reflect the passage of time.
     292 *
     293 *  Input parameters:   NONE
     294 *
     295 *  Output parameters:  NONE
     296 */
     297
     298void _Timer_Process_ticks_chain(void)
     299{
     300  Watchdog_Interval snapshot;
     301  Watchdog_Interval ticks;
     302
     303  snapshot = _Watchdog_Ticks_since_boot;
     304  if ( snapshot >= _Timer_Server_ticks_last_time )
     305     ticks = snapshot - _Timer_Server_ticks_last_time;
     306  else
     307     ticks = (0xFFFFFFFF - _Timer_Server_ticks_last_time) + snapshot;
     308 
     309  _Timer_Server_ticks_last_time = snapshot;
     310  _Watchdog_Adjust( &_Timer_Ticks_chain, WATCHDOG_FORWARD, ticks );
     311}
     312
     313/*PAGE
     314 *
     315 *  _Timer_Server_Process_seconds_chain
     316 *
     317 *  This routine is responsible for adjusting the list of task-based
     318 *  time of day timers to reflect the passage of time.
     319 *
     320 *  Input parameters:   NONE
     321 *
     322 *  Output parameters:  NONE
     323 */
     324
     325void _Timer_Process_seconds_chain(void)
     326{
     327  Watchdog_Interval snapshot;
     328  Watchdog_Interval ticks;
     329
     330  /*
     331   *  Process the seconds chain.  Start by checking that the Time
     332   *  of Day (TOD) has not been set backwards.  If it has then
     333   *  we want to adjust the _Timer_Seconds_chain to indicate this.
     334   */
     335
     336  snapshot =  _TOD_Seconds_since_epoch;
     337  if ( snapshot > _Timer_Server_seconds_last_time ) {
     338    /*
     339     *  This path is for normal forward movement and cases where the
     340     *  TOD has been set forward.
     341     */
     342
     343    ticks = snapshot - _Timer_Server_seconds_last_time;
     344    _Watchdog_Adjust( &_Timer_Seconds_chain, WATCHDOG_FORWARD, ticks );
     345
     346  } else if ( snapshot < _Timer_Server_seconds_last_time ) {
     347     /*
     348      *  The current TOD is before the last TOD which indicates that
     349      *  TOD has been set backwards.
     350      */
     351
     352     ticks = _Timer_Server_seconds_last_time - snapshot;
     353     _Watchdog_Adjust( &_Timer_Seconds_chain, WATCHDOG_BACKWARD, ticks );
     354  }
     355  _Timer_Server_seconds_last_time = snapshot;
     356}
     357
Note: See TracChangeset for help on using the changeset viewer.