CLOCK_MONOTONIC_RAW

From: Erik Thiele <hidden>
Date: 2009-08-14 15:44:43

hi

clock_gettime talks about CLOCK_MONOTONIC_RAW
clock_getres talks about CLOCK_MONOTONIC_RAW
clock_nanosleep does NOT talk about CLOCK_MONOTONIC_RAW
timerfd_create does NOT talk about CLOCK_MONOTONIC_RAW
there seem to be other functions relevant to CLOCK_* selection that 
don't specify all

the ones that do not talk about the CLOCK_MONOTONIC_RAW should say why 
it is not possible to use that parameter or should specify that it is 
indeed possible to use that parameter.

maybe there should instead be a manpage "linux_clocks" that explains all 
clocks instead of replicating the information on the individual manpages.

manpage of clock_nanosleep should say that using CLOCK_MONOTONIC_RAW is 
the only possibility on linux to really wait a specific amount of time 
without being in danger of ntp fiddling around because CLOCK_MONOTONIC 
still leaves us with the problem of time slew generated by ntp.

the manpage could also say that CLOCK_MONOTONIC_RAW is not always 
"better" than CLOCK_MONOTONIC since it is on the one hand free of 
slewing, but on the other hand it has the problem that it might run too 
fast or too slow depending on hardware properties. at least it should 
run at constant speed, which CLOCK_MONOTONIC with ntp does certainly not.

maybe you should make a table to explain that:

CLOCK_REALTIME
- can jump
- can slew
- if ntp is running this clock is always kept close to GMT. even if 
hardware is not 100% correct, ntp will correct everything over time.

CLOCK_MONOTONIC
- cannot jump
- can slew !!! (because of ntp)
- it is not kept in sync with GMT. but the "speed" of seconds is kept in 
sync with GMT by varying it constantly by ntp.

CLOCK_MONOTONIC_RAW
- cannot jump
- cannot slew !
- the speed of seconds is not the same as the speed of GMT seconds since 
the hardware timer is never 100% exact and ntp daemon does NOT have 
influence here


in my program i have a main scheduler event loop which needs to do 
absolute timer events with nanosecond precision and independent of ntp 
time slewing and jumping.

- to get nanosecond precision i need to use a dual threaded approach 
where one thread has the only duty to wait with clock_nanosleep and 
report timer events over a pipe() to the mother thread since epoll_wait 
is only with millisecond resolution

- to get the independence of ntp time jumping i use CLOCK_MONOTONIC

- to get the independence of ntp time slewing i'd like to use 
CLOCK_MONOTONIC_RAW but it's at least not documented?


thanks!
cya

-- 
Erik Thiele


--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help