Created
June 27, 2013 08:36
-
-
Save cdcs/5874932 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void rtems_time_travel(long ticks) | |
{ | |
/* a clock tick in a timespec structure */ | |
struct timespec tick; | |
/* number of seconds elapsed */ | |
uint32_t seconds; | |
/* Convert the tick quantum to a timespec */ | |
/* convert a clock tick into nanoseconds */ | |
tick.tv_nsec = _TOD_Microseconds_per_tick * 1000 * ticks; | |
/* the number of seconds is 0 (assumed the clock tick fits in the | |
* nanoseconds field */ | |
tick.tv_sec = 0; | |
/* Update the counter of ticks since boot */ | |
_Watchdog_Ticks_since_boot += ticks; | |
/* Update the timespec format uptime */ | |
(void) _Timespec_Add_to(&_TOD_Uptime , &tick); | |
/* Update the timespec format TOD */ | |
seconds = _Timespec_Add_to(&_TOD_Now , &tick); | |
/* adjust ticks chain*/ | |
_Watchdog_Adjust_ticks(ticks); | |
/* If one second has passed (or more)*/ | |
if(seconds > 0) { | |
/* adjust seconds chain */ | |
_Watchdog_Adjust_seconds(WATCHDOG_FORWARD, seconds); | |
} | |
} | |
/* watchdog.inl */ | |
/** | |
* @brief adjust the watchdog ticks chain forward or backwards by a specified | |
* amount of units | |
* | |
* This routine adjusts the ticks watchdog chain in the forward | |
* direction for UNITS ticks (ticks are monotonic). This is invoked when there | |
* a partition context switch | |
* @param[in] units the amount of units to adjust the chain | |
*/ | |
RTEMS_INLINE_ROUTINE void _Watchdog_Adjust_ticks( | |
Watchdog_Interval units | |
) | |
{ | |
/* adjust the watchdog seconds chain */ | |
_Watchdog_Adjust(&_Watchdog_Ticks_chain , WATCHDOG_FORWARD , units); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment