Changeset 875fff0a in rtems


Ignore:
Timestamp:
07/23/14 20:35:35 (8 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, 5, master
Children:
0a84c298
Parents:
3b6352d
git-author:
Joel Sherrill <joel.sherrill@…> (07/23/14 20:35:35)
git-committer:
Joel Sherrill <joel.sherrill@…> (07/23/14 21:53:24)
Message:

Add _TOD_Adjust to SCORE TOD Handler.

This lays the proper structure for doing future work on
time adjustment algorithms. Any TOD adjustments should be
requested at the API level and performed at the SCORE level.

Additionally updated a test.

Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/adjtime.c

    r3b6352d r875fff0a  
    4545{
    4646  Timestamp_Control  delta_as_timestamp;
    47   Timestamp_Control  tod_as_timestamp;
    48   Timestamp_Control *tod_as_timestamp_ptr;
    4947
    5048  /*
     
    5452    rtems_set_errno_and_return_minus_one( EINVAL );
    5553
     54  if ( delta->tv_usec >= TOD_MICROSECONDS_PER_SECOND )
     55    rtems_set_errno_and_return_minus_one( EINVAL );
     56
    5657  /*
    57    * Currently, RTEMS does the adjustment in one movement.
     58   * An adjustment of zero is pretty easy.
     59   */
     60  if ( delta->tv_sec == 0 && delta->tv_usec == 0 )
     61    return 0;
     62
     63  /*
     64   * Currently, RTEMS does the adjustment in one movement so there
     65   * is no way an adjustment was currently underway.
     66   *
    5867   * Given interest, requirements, and sponsorship, a future
    5968   * enhancement would be to adjust the time in smaller increments
     
    7281
    7382  /*
    74    * This prevents context switches while we are adjusting the TOD
     83   * Now apply the adjustment
    7584   */
    76 
    77   _Thread_Disable_dispatch();
    78 
    79     tod_as_timestamp_ptr =
    80       _TOD_Get_with_nanoseconds( &tod_as_timestamp, &_TOD.now );
    81 
    82 
    83     _Timestamp_Add_to( tod_as_timestamp_ptr, &delta_as_timestamp );
    84 
    85     _TOD_Set_with_timestamp( tod_as_timestamp_ptr );
    86 
    87   _Thread_Enable_dispatch();
     85  _TOD_Adjust( delta_as_timestamp );
    8886
    8987  return 0;
  • cpukit/score/Makefile.am

    r3b6352d r875fff0a  
    320320libscore_a_SOURCES += src/coretod.c src/coretodset.c src/coretodget.c \
    321321    src/coretodgetuptimetimespec.c src/coretodtickle.c \
    322     src/coretodsecondssinceepoch.c \
    323     src/coretodtickspersec.c
     322    src/coretodsecondssinceepoch.c src/coretodtickspersec.c \
     323    src/coretodadjust.c
    324324
    325325## WATCHDOG_C_FILES
  • cpukit/score/include/rtems/score/todimpl.h

    r3b6352d r875fff0a  
    323323}
    324324
     325/**
     326 * @brief Adjust the Time of Time
     327 *
     328 * This method is used to adjust the current time of day by the
     329 * specified amount.
     330 *
     331 * @param[in] delta is the amount to adjust
     332 */
     333void _TOD_Adjust(
     334  const Timestamp_Control timestamp
     335);
     336
    325337RTEMS_INLINE_ROUTINE void _TOD_Set_nanoseconds_since_last_tick_handler(
    326338  TOD_Nanoseconds_since_last_tick_routine routine
  • testsuites/psxtests/psxtime/psxtime.scn

    r3b6352d r875fff0a  
    66adjtime - NULL delta - EINVAL
    77adjtime - delta out of range - EINVAL
     8adjtime - delta range of 0 - OK
    89adjtime - delta too small - do nothing
    910adjtime - delta too small - do nothing, olddelta=NULL
  • testsuites/psxtests/psxtime/test.c

    r3b6352d r875fff0a  
    1 /*
    2  *  This test exercises the time of day services via the Classic
    3  *  and POSIX APIs to make sure they are consistent.
     1/**
     2 * @file
    43 *
    5  *  COPYRIGHT (c) 1989-2009.
     4 * This test exercises the time of day services via the Classic
     5 * and POSIX APIs to make sure they are consistent. It additionally
     6 * exericses the adjtime() method.
     7 *
     8 */
     9
     10/*
     11 *  COPYRIGHT (c) 1989-2014.
    612 *  On-Line Applications Research Corporation (OAR).
    713 *
     
    129135
    130136  puts( "adjtime - delta out of range - EINVAL" );
     137  delta.tv_sec = 0;
    131138  delta.tv_usec = 1000000000; /* 100 seconds worth */
    132139  sc = adjtime( &delta, &olddelta );
    133140  rtems_test_assert( sc == -1 );
    134141  rtems_test_assert( errno == EINVAL );
     142
     143  puts( "adjtime - delta range of 0 - OK" );
     144  delta.tv_sec = 0;
     145  delta.tv_usec = 0;
     146  sc = adjtime( &delta, &olddelta );
     147  rtems_test_assert( sc == 0 );
    135148
    136149  puts( "adjtime - delta too small - do nothing" );
Note: See TracChangeset for help on using the changeset viewer.