问题描述
根据Ubuntu下的Linux手册页
According to the Linux man page under Ubuntu
CLOCK_MONOTONIC
Clock that cannot be set and represents monotonic time since
some unspecified starting point.
CLOCK_MONOTONIC_RAW (since Linux 2.6.28; Linux-specific)
Similar to CLOCK_MONOTONIC, but provides access to a raw hard‐
ware-based time that is not subject to NTP adjustments.
根据韦伯斯特在线词典,单调意味着:
According to the webster online dictionary Monotonic means:
换句话说,它不会向后跳.我可以看到,如果您正在计时一些代码,这将是一个重要的属性.
In other words, it won't jump backwards. I can see that this would be an important property if you were timing some code.
但是,普通版本和原始版本之间的区别尚不清楚.有人可以阐明NTP如何仍然影响CLOCK_MONOTONIC吗?
However, the difference between the normal and raw version isn't clear. Can someone shed some light into how NTP can still affect CLOCK_MONOTONIC?
推荐答案
CLOCK_MONOTONIC
从未遇到由于NTP时间调整而导致的中断,但是 发生了频率变化,因为NTP了解到两者之间存在什么错误.本地振荡器和上游服务器.
CLOCK_MONOTONIC
never experiences discontinuities due to NTP time adjustments, but it does change in frequency as NTP learns what error exists between the local oscillator and the upstream servers.
CLOCK_MONOTONIC_RAW
只是本地振荡器,不受NTP约束.如果您想针对由于NTP而无法解决问题的时钟实现其他时间同步算法,这可能非常有用.尽管ntpd(NTP协议的参考实现和最广泛的NTP守护程序)被称为具有时间调整功能的温和",但准确地说是绝对时间比较温和.它愿意将时钟摆幅降低500ppm,如果您能够相对于其他标准来测量时钟频率,那将是非常显着的.
CLOCK_MONOTONIC_RAW
is simply the local oscillator, not disciplined by NTP. This could be very useful if you want to implement some other time synchronization algorithm against a clock which is not fighting you due to NTP. While ntpd (the reference implementation of NTP protocol and the most widespread NTP daemon) is reputed to be "gentle" with time adjustments, it's more accurate to say it's gentle with the absolute time. It's willing to slew the clock by 500ppm which is pretty dramatic if you're in a position to measure your clock frequency against some other standard.
CLOCK_MONOTONIC_RAW
的实用程序将受到限制,直到pthread_timedwait_monotonic
之类的设施提供使用该时基的选项为止.
The utility of CLOCK_MONOTONIC_RAW
is going to be limited until facilities like pthread_timedwait_monotonic
offer an option to use that timebase.
这篇关于CLOCK_MONOTONIC&之间有什么区别? CLOCK_MONOTONIC_RAW?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!