Re: clock_nanosleep and NTP drift correction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/13/2012 02:09 PM, Luis Claudio R. Goncalves wrote:

> | clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, NULL);
> | within the application's main loop.
> | The value of "ts" will be incremented after every call.
> | 
> CLOCK_MONOTONIC is not affected by NTP nor any adjusts to date and time
> that the admin/user may perform.

I beg to differ. CLOCK_MONOTONIC is frequency adjusted. Though it won't
jump, it will slew. From man clock_gettime:

  CLOCK_MONOTONIC
         Clock  that  cannot  be  set and represents monotonic time since
         some unspecified starting point.  This clock is not affected  by
         discontinuous  jumps  in  the  system  time (e.g., if the system
         administrator manually changes the clock), but  is  affected  by
         the incremental adjustments performed by adjtime(3) and NTP.


Which means it's more or less what the original poster wants.


Though it's LaTeX, here's a table I've created a couple of months ago:

\begin{table}
  \begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}ccccc}
    \toprule
    {\scshape clock name}& {\scshape posix}& {\scshape set}& {\scshape
adjust}&
{\scshape jump} &
{\scshape slew}\\
    \midrule
\texttt{CLOCK_REALTIME}& yes& yes& yes& yes& yes\\
\texttt{CLOCK_MONOTONIC}& yes& no& yes& no& yes\\
\texttt{CLOCK_MONOTONIC_RAW}& no& no& no& no& no\\
\texttt{CLOCK_PROCESS_CPUTIME_ID}& yes& no& no& SMP& no\\
\texttt{CLOCK_THREAD_CPUTIME_ID}& yes& no& no& SMP& no\\
\bottomrule
  \end{tabular*}
\caption{Multiple clock sources as required by
POSIX and the Linux-specific \texttt{CLOCK_MONOTONIC_RAW}.
Only \texttt{CLOCK_REALTIME}, the clock shown to the user as system
time, can be set
explicitly.
It is not monotonic, the clock
can jump back and forth or slew when being frequency adjusted. In
contrast, \texttt{CLOCK_MONOTONIC} is strictly monotonic, but can still
be frequency adjusted and will hence slew.
\texttt{CLOCK_MONOTONIC_RAW} does not exhibit any of
these deficiencies, but has no relation to UTC at all.
It is ideal for reliably tracking foreign clocks, e.g., timestamps in
networked or FireWire audio.
The two CPUTIME clocks
accumulate the time a process or thread has spent running on the
CPU. Since these clocks rely on registers that can be local to an
individual CPU or core, care must be taken on SMP systems.}
  \label{tab:clocks}
\end{table}

(the adjust and slew columns are somewhat redundant)



Side note: if NTP is too coarse, maybe it's worth having a look at PTP.


HTH
--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux