CLOCK_MONOTONIC_RAW never supported clock_nanosleep() since it was introduced in Linux 2.6.28. This has also been explicitly fixed so as not to have this support in 2.6.32 due to a trick . After that, the code was refactored several times, but there is no support for CLOCK_MONOTONIC_RAW in clock_nanosleep() , and I could not find any comments about this.
At a minimum, the fact that there was a patch that explicitly turned this feature off, and it went through all the reviews, tells us that this does not look like a big problem for kernel developers. So, at the moment (4.7) the only thing that supports CLOCK_MONOTONIC_RAW : clock_getres() and clock_gettime() .
Speaking of settings, as Rich CLOCK_MONOTONIC has already noted , it depends on the speed settings only by the nature of this watch. This is because hrtimer_interrupt() starts its queues with the changed monotone time value ( ktime_get_update_offsets_now () â timekeeping_get_ns () â timekeeping_delta_to_ns () and works with xtime_nsec , which can be changed ). Actually, looking at this code, I'm probably no longer surprised that CLOCK_MONOTONIC_RAW does not support clock_nanosleep() (and probably won't be in the future) - The adjusted use of a monotone clock seems to be the basis for hrtimers.
As for the alternatives, I think they are not. nanosleep() uses the same CLOCK_MONOTONIC , setitimer() has its own set of timers , alarm() uses ITIMER_REAL (the same as setitimer() ) , which ( with some indirectness ) is also our good old friend CLOCK_MONOTONIC . What else do we have? I do not think anything.
As an unrelated side of the note, there is an interesting remark in that if you call clock_nanosleep() for a relative interval (i.e. not TIMER_ABSTIME ), then CLOCK_REALTIME actually becomes a synonym for CLOCK_MONOTONIC .
Roman khimov
source share