Use CLOCK_MONOTONIC_RAW instead of CLOCK_MONOTONIC for Instant #77807
Labels
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
O-linux
Operating system: Linux
T-libs
Relevant to the library team, which will review and decide on the PR/issue.
Uh oh!
There was an error while loading. Please reload this page.
According to man pages,
CLOCK_MONOTONIC_RAW
doesn't get adjustments from NTP oradjtime
, whereasCLOCK_MONOTONIC
does. This seems ideal forInstant
. CLOCK_MONOTONIC_RAW appears to prevent slewing or jumping, closer matching user expectations aboutInstant
(despite the fact that Instant is explicitly allowed to jump forward and slew)This wasn't done earlier due to Rust's minimum supported Linux kernel version (now 2.6.32) since CLOCK_MONOTONIC_RAW was added in 2.6.28. See also #37902
I'd also like to change thread::sleep's implementation to use clock_nanosleep(
CLOCK_MONOTONIC_RAW
) from it's currentnanosleep()
. Note thatfrom linux.die. This has negative implications for the implementation of thread::sleep on BSD, which should probably use CLOCK_MONOTONIC.
Of course, CLOCK_MONATONIC_RAW is Linux-specific, so other Unix platforms will still use CLOCK_MONATONIC
The text was updated successfully, but these errors were encountered: