aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/time/posix-timers.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 88517dcfe0ca..58c0f60b132f 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -72,6 +72,7 @@ static DEFINE_SPINLOCK(hash_lock);
72 72
73static const struct k_clock * const posix_clocks[]; 73static const struct k_clock * const posix_clocks[];
74static const struct k_clock *clockid_to_kclock(const clockid_t id); 74static const struct k_clock *clockid_to_kclock(const clockid_t id);
75static const struct k_clock clock_realtime, clock_monotonic;
75 76
76/* 77/*
77 * we assume that the new SIGEV_THREAD_ID shares no bits with the other 78 * we assume that the new SIGEV_THREAD_ID shares no bits with the other
@@ -750,6 +751,18 @@ static void common_hrtimer_arm(struct k_itimer *timr, ktime_t expires,
750 enum hrtimer_mode mode; 751 enum hrtimer_mode mode;
751 752
752 mode = absolute ? HRTIMER_MODE_ABS : HRTIMER_MODE_REL; 753 mode = absolute ? HRTIMER_MODE_ABS : HRTIMER_MODE_REL;
754 /*
755 * Posix magic: Relative CLOCK_REALTIME timers are not affected by
756 * clock modifications, so they become CLOCK_MONOTONIC based under the
757 * hood. See hrtimer_init(). Update timr->kclock, so the generic
758 * functions which use timr->kclock->clock_get() work.
759 *
760 * Note: it_clock stays unmodified, because the next timer_set() might
761 * use ABSTIME, so it needs to switch back.
762 */
763 if (timr->it_clock == CLOCK_REALTIME)
764 timr->kclock = absolute ? &clock_realtime : &clock_monotonic;
765
753 hrtimer_init(&timr->it.real.timer, timr->it_clock, mode); 766 hrtimer_init(&timr->it.real.timer, timr->it_clock, mode);
754 timr->it.real.timer.function = posix_timer_fn; 767 timr->it.real.timer.function = posix_timer_fn;
755 768