Module: xenomai-forge Branch: next Commit: 331d69476ea89e5d92e4b2c2ef8ba6e0aaad5f1b URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=331d69476ea89e5d92e4b2c2ef8ba6e0aaad5f1b
Author: Philippe Gerum <r...@xenomai.org> Date: Sun Sep 28 17:03:44 2014 +0200 alchemy/timer: drop TSC reading and conversion ops from the API Due to the accumulation of rounding errors, using raw TSC counts for measuring long timespans may yield (increasingly) wrong results. In short, either we guarantee stable computations with counts of nanoseconds, or with TSC instead, regardless of the clock source frequency, but we can't provide such guarantee for both. From an API standpoint, the nanosecond unit is definitely the best option as the meaning won't vary between clock sources. Avoiding the overhead of the tsc->ns conversion as a justification to use raw TSC counts does not fly anymore, as all architectures implement fast arithmetics for this operation over Cobalt, and Mercury's (virtual) TSC is actually mapped over CLOCK_MONOTONIC. Therefore, all TSC reading and ns<->tsc conversion services are removed from the Alchemy API to prevent misleading results. Users should measure timespans (or get timestamps) as counts of nanoseconds as returned by rt_timer_read() instead. The following calls are dropped from the API: - rt_timer_tsc() - rt_timer_ns2tsc() - rt_timer_tsc2ns() In addition, rt_timer_inquire() does not return the TSC count anymore. --- include/alchemy/timer.h | 39 ++++++--------------------------------- lib/alchemy/timer.c | 9 ++++----- 2 files changed, 10 insertions(+), 38 deletions(-) diff --git a/include/alchemy/timer.h b/include/alchemy/timer.h index 5c1cc08..7b3837b 100644 --- a/include/alchemy/timer.h +++ b/include/alchemy/timer.h @@ -38,8 +38,8 @@ typedef sticks_t SRTIME; * @brief Timer status descriptor * @anchor RT_TIMER_INFO * - * This structure reports various static and runtime information about - * the timer, returned by a call to rt_timer_inquire(). + * This structure reports information about the Alchemy clock, + * returned by a call to rt_timer_inquire(). */ typedef struct rt_timer_info { /** @@ -47,22 +47,10 @@ typedef struct rt_timer_info { */ RTIME period; /** - * Current time stamp counter value. The source of this - * information is hardware-dependent, and does not depend on - * the per-process clock settings. Consecutive readings from a - * single CPU are guaranteed to be monotonically incrementing, - * however readings may not be synchronized on multi-core - * hardware if the time stamp counter is local to each CPU. - * Therefore, whether consecutive readings from different CPUs - * are consistent and monotonically incrementing depends on - * the underlying TSC source. - */ - RTIME tsc; - /** - * Current monotonic date, based on the time stamp counter - * value. The date is expressed in clock ticks, therefore - * depends on the Alchemy clock resolution applicable to the - * current process. + * Current monotonic date expressed in clock ticks. The + * duration of a tick depends on the Alchemy clock resolution + * for the process (see --alchemy-clock-resolution option, + * defaults to 1 nanosecond). */ RTIME date; } RT_TIMER_INFO; @@ -118,21 +106,6 @@ static inline RTIME rt_timer_read(void) return clockobj_get_time(&alchemy_clock); } -static inline RTIME rt_timer_tsc(void) -{ - return clockobj_get_tsc(); -} - -static inline SRTIME rt_timer_ns2tsc(SRTIME ns) -{ - return clockobj_ns_to_tsc(ns); -} - -static inline SRTIME rt_timer_tsc2ns(SRTIME tsc) -{ - return clockobj_tsc_to_ns(tsc); -} - SRTIME rt_timer_ns2ticks(SRTIME ns); SRTIME rt_timer_ticks2ns(SRTIME ticks); diff --git a/lib/alchemy/timer.c b/lib/alchemy/timer.c index d37a9d7..7c08233 100644 --- a/lib/alchemy/timer.c +++ b/lib/alchemy/timer.c @@ -76,12 +76,12 @@ SRTIME rt_timer_ticks2ns(SRTIME ticks) /** * @fn void rt_timer_inquire(RT_TIMER_INFO *info) - * @brief Inquire about the Xenomai core timer. + * @brief Inquire about the Alchemy clock. * - * Return status information of the Xenomai core timer. + * Return status information about the Alchemy clock. * - * @param info The address of a structure the status data will be - * written to. + * @param info The address of a @ref RT_TIMER_INFO "structure" to fill + * with the clock information. * * @apitags{unrestricted} */ @@ -89,7 +89,6 @@ void rt_timer_inquire(RT_TIMER_INFO *info) { info->period = clockobj_get_resolution(&alchemy_clock); info->date = clockobj_get_time(&alchemy_clock); - info->tsc = clockobj_get_tsc(); } /** _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git