]> rtime.felk.cvut.cz Git - orte.git/commit
Use CLOCK_MONOTONIC rather than CLOCK_REALTIME
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 14 Mar 2015 15:39:35 +0000 (16:39 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 14 Mar 2015 15:44:05 +0000 (16:44 +0100)
commitae9660de4bd0ccb65f1005ced56bb6e05d50bf11
treeb4d6a2bf45314ef663a7a4661674667e4022814d
parent9a1a32554333f21a49dca82c04b9f31943004bd4
Use CLOCK_MONOTONIC rather than CLOCK_REALTIME

This changes the clock used internally by ORTE for timestamps in the
protocol and for timing of internal operations. Previously,
CLOCK_REALTIME was used, probably because it is the default clock used
by pthread_cond_timedwait(). Using CLOCK_REALTIME has the disadvantage
that the time can "jump", e.g. when the clock is adjusted by ntpdate.
This causes the applications to stop publishing, which results in them
disappearing from the domain even through their processes still run.

The solution implemented in this commit is to switch the clock to
CLOCK_MONOTONIC, which does not jump. This should have no effect at the
protocol level, because the semantic of timestamps is not defined in the
spec. This was also tested by running the implementations with and
without this change against each other.

In future, it might be a good idea to use different clocks for
timestamps in the protocol and for timing of internal operations (e.g.
ORTEAppSendThread()). I'm not sure what happens in the following two
cases:

1) When one node is suspended to RAM/disk, CLOCK_MONOTONIC stops for the
   time of suspension and it is not clear to me what other nodes that
   run continuously do when the suspended node resumes.

2) When a node is rebooted, the monotonic clock starts from zero, i.e.
   there is a "jump". I'm not sure, whether IDs of the application
   before and after reboot will be different. UDP ports, that are a part
   of the ID should be randomized, but the question is how good this
   randomization is. If the ID is the same before and after reboot some
   problems might also appear.
configure.ac
orte/include/orte/orte_config_omk_linux.h
orte/liborte/ORTEDomain.c
orte/liborte/RTPSCSTWriter.c
orte/liborte/htimerNtp.c