CLOCK_MONOTONIC 和有什么区别?CLOCK_MONOTONIC_RAW? [英] What is the difference between CLOCK_MONOTONIC & CLOCK_MONOTONIC_RAW?

查看:187
本文介绍了CLOCK_MONOTONIC 和有什么区别?CLOCK_MONOTONIC_RAW?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 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.

根据韦氏在线词典 Monotonic 的意思:

According to the webster online dictionary Monotonic means:

2:具有从不增加或从不增加的属性随着自变量或下标的值递减的条款增加.

2: having the property either of never increasing or of never decreasing as the values of the independent variable or the subscripts of the terms increase.

换句话说,它不会向后跳.我可以看出,如果您正在为某些代码计时,这将是一个重要的属性.

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 守护进程)被认为对时间调整温和",但更准确地说,它对绝对时间是温和的.它愿意将时钟摆动 500 ppm,如果您能够根据其他标准测量时钟频率,这是非常显着的.

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆