Changeset cae389ba in rtems


Ignore:
Timestamp:
Sep 1, 2011, 6:24:47 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, 5, master
Children:
36c187a0
Parents:
ac9d2ecc
Message:

2011-09-01 Joel Sherrill <joel.sherrilL@…>

PR 1895/cpukit

  • score/src/coretodmsecstoticks.c, score/src/coretodusectoticks.c, score/src/timespectoticks.c: Ensure time conversions to ticks do not ignore partial tick and return 1 less than desired.
Location:
cpukit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    rac9d2ecc rcae389ba  
     12011-09-01      Joel Sherrill <joel.sherrilL@OARcorp.com>
     2
     3        PR 1895/cpukit
     4        * score/src/coretodmsecstoticks.c, score/src/coretodusectoticks.c,
     5        score/src/timespectoticks.c: Ensure time conversions to ticks do not
     6        ignore partial tick and return 1 less than desired.
     7
    182011-09-01      Petr Benes <benesp16@fel.cvut.cz>
    29
  • cpukit/score/src/coretodmsecstoticks.c

    rac9d2ecc rcae389ba  
    1 /*  COPYRIGHT (c) 1989-2008.
     1/*  COPYRIGHT (c) 1989-2011.
    22 *  On-Line Applications Research Corporation (OAR).
    33 *
     
    2222)
    2323{
    24   return (milliseconds / rtems_configuration_get_milliseconds_per_tick());
     24  uint32_t ticks;
     25  uint32_t milliseconds_per_tick;
     26
     27  /**
     28   *  We should ensure the ticks not be truncated by integer division.  We
     29   *  need to have it be greater than or equal to the requested time.  It
     30   *  should not be shorter.
     31   */
     32  milliseconds_per_tick = rtems_configuration_get_milliseconds_per_tick();
     33  ticks                 = milliseconds / milliseconds_per_tick;
     34  if ( (milliseconds % milliseconds_per_tick) != 0 )
     35    ticks += 1;
     36
     37  return ticks;
    2538}
  • cpukit/score/src/coretodusectoticks.c

    rac9d2ecc rcae389ba  
    1 /*  COPYRIGHT (c) 1989-2008.
     1/*  COPYRIGHT (c) 1989-2011.
    22 *  On-Line Applications Research Corporation (OAR).
    33 *
     
    2222)
    2323{
    24   return (microseconds / rtems_configuration_get_microseconds_per_tick());
     24  uint32_t ticks;
     25  uint32_t microseconds_per_tick;
     26
     27  /**
     28   *  We should ensure the ticks not be truncated by integer division.  We
     29   *  need to have it be greater than or equal to the requested time.  It
     30   *  should not be shorter.
     31   */
     32  microseconds_per_tick = rtems_configuration_get_microseconds_per_tick();
     33  ticks                 = microseconds / microseconds_per_tick;
     34  if ( (microseconds % microseconds_per_tick) != 0 )
     35    ticks += 1;
     36
     37  return ticks;
    2538}
  • cpukit/score/src/timespectoticks.c

    rac9d2ecc rcae389ba  
    3636{
    3737  uint32_t  ticks;
     38  uint32_t  nanoseconds_per_tick;
    3839
    3940  if ( (time->tv_sec == 0) && (time->tv_nsec == 0) )
    4041    return 0;
    4142
    42   ticks  = time->tv_sec * TOD_TICKS_PER_SECOND;
     43  /**
     44   *  We should ensure the ticks not be truncated by integer division.  We
     45   *  need to have it be greater than or equal to the requested time.  It
     46   *  should not be shorter.
     47   */
     48  ticks                 = time->tv_sec * TOD_TICKS_PER_SECOND;
     49  nanoseconds_per_tick  = rtems_configuration_get_nanoseconds_per_tick();
     50  ticks                += time->tv_nsec / nanoseconds_per_tick;
    4351
    44   ticks += time->tv_nsec / rtems_configuration_get_nanoseconds_per_tick();
     52  if ( (time->tv_nsec % nanoseconds_per_tick) != 0 )
     53    ticks += 1;
    4554
    46   if (ticks)
    47     return ticks;
    48 
    49   return 1;
     55  return ticks;
    5056}
Note: See TracChangeset for help on using the changeset viewer.