3 ms·
This is why clock_gettime() allows you to specify which clock to use. According to POSIX, CLOCK_MONOTONIC is not supposed to have any sudden jumps due to time a
by hetman 10y ago
This is why clock_gettime() allows you to specify which clock to use. According to POSIX, CLOCK_MONOTONIC is not supposed to have any sudden jumps due to time adjustments or leap seconds, but can be adjusted for the gradual drift the clock experiences with respect to real world time. It seems perfect for your use case (if you don't want the skew adjustment there's also CLOCK_MONOTONIC_RAW, but since there is no skew adjustment it's only reasonably accurate for events that are close together).
- ambrop7 10y agoCLOCK_MONOTONIC is good, but it's a local clock without a defined reference. So you can't use it on the network to synchronize different computers or otherwise communicate absolute timestamps. There should be a CLOCK_REALTIME_RAW or something that gives you the TAI time (UTC without correction for leap seconds).
- hetman 10y agoAh, I see what you mean. A standard API for synchronising non-local events would definitely make life easier.
- bonzini 10y agoLinux has CLOCK_TAI.
- ambrop7 10y agoThat's great to know. I had no idea since it's not mentioned in the man page for clock_gettime (part of the "Linux Programmer's Manual"). Apparently the man pages are out of date.