According to the hrtimer.h, HRTIMER_MODE_ABS means time value is absolute whereas HRTIMER_MODE_REL means time value is relative to now.
When used in the context of hrtimer_init, CLOCK_MONOTONIC or CLOCK_REALTIME can be also be chosen. This means that hrtimers can be initialized in several ways such as below.
hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
hrtimer_init(&timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
hrtimer_init(&timer, CLOCK_REALTIME, HRTIMER_MODE_REL);
Upon inspection of hrtimer.c, the 4th intialization has no effect because the clock_id is set back to CLOCK_MONOTONIC if mode is not HRTIMER_MODE_ABS upon initialization.
if (clock_id == CLOCK_REALTIME && mode != HRTIMER_MODE_ABS)
clock_id = CLOCK_MONOTONIC;
So that leaves us with 3 possible behaviours. Now I understand the CLOCK_REALTIME is affected by system time therefore might be discontinuous, whereas CLOCK_MONOTONIC is the opposite (i.e. it is always ticking forward).
The following is my understanding of the possible behaviours, but they seem way too similar and I am unsure which to choose.
1) hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
The clock is continuous and time always expires after an absolute time of N. Changes in system time does not affect the clock therefore it does not affect expiry time.
2) hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
The clock is continuous and time expires N time from now. Changes in system time does not affect the clock therefore it does not affect expiry time from 'now'.
3) hrtimer_init(&timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
The clock can be set but any changes to system clock still does not affect expiry, because the timer is set to expire at an absolute time of N.
I realized my interpretation could be wrong because the behaviours all look similar. Can anyone shed light on this?