diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -706,6 +706,7 @@ { struct bintime bt, bbt; struct timespec tts; + sbintime_t rem; switch (timo->clockid) { @@ -738,14 +739,24 @@ return (0); } *sbt = bttosbt(bt); + + /* + * Check if the absolute time should be aligned to + * avoid firing multiple timer events in non-periodic + * timer mode. + */ switch (timo->clockid) { case CLOCK_REALTIME_FAST: case CLOCK_MONOTONIC_FAST: case CLOCK_UPTIME_FAST: - *sbt += tc_tick_sbt; + rem = *sbt % tc_tick_sbt; + if (__predict_true(rem != 0)) + *sbt += tc_tick_sbt - rem; break; case CLOCK_SECOND: - *sbt += SBT_1S; + rem = *sbt % SBT_1S; + if (__predict_true(rem != 0)) + *sbt += SBT_1S - rem; break; } *flags = C_ABSOLUTE;