Changeset cae389ba in rtems
- Timestamp:
- 09/01/11 18:24:47 (11 years ago)
- Branches:
- 4.11, 5, master
- Children:
- 36c187a0
- Parents:
- ac9d2ecc
- Location:
- cpukit
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/ChangeLog
rac9d2ecc rcae389ba 1 2011-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 1 8 2011-09-01 Petr Benes <benesp16@fel.cvut.cz> 2 9 -
cpukit/score/src/coretodmsecstoticks.c
rac9d2ecc rcae389ba 1 /* COPYRIGHT (c) 1989-20 08.1 /* COPYRIGHT (c) 1989-2011. 2 2 * On-Line Applications Research Corporation (OAR). 3 3 * … … 22 22 ) 23 23 { 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; 25 38 } -
cpukit/score/src/coretodusectoticks.c
rac9d2ecc rcae389ba 1 /* COPYRIGHT (c) 1989-20 08.1 /* COPYRIGHT (c) 1989-2011. 2 2 * On-Line Applications Research Corporation (OAR). 3 3 * … … 22 22 ) 23 23 { 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; 25 38 } -
cpukit/score/src/timespectoticks.c
rac9d2ecc rcae389ba 36 36 { 37 37 uint32_t ticks; 38 uint32_t nanoseconds_per_tick; 38 39 39 40 if ( (time->tv_sec == 0) && (time->tv_nsec == 0) ) 40 41 return 0; 41 42 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; 43 51 44 ticks += time->tv_nsec / rtems_configuration_get_nanoseconds_per_tick(); 52 if ( (time->tv_nsec % nanoseconds_per_tick) != 0 ) 53 ticks += 1; 45 54 46 if (ticks) 47 return ticks; 48 49 return 1; 55 return ticks; 50 56 }
Note: See TracChangeset
for help on using the changeset viewer.