1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/ztimer: fix re-scheduling of timers

If the timer at the head of a ztimer clock's timer list is re-scheduled
(ztimer_set() called on an already set timer) and the timer is no longer
at the head after being re-scheduled, clock-ops->set() is never called
from inside ztimer_set(), and the underlying timer is left with an ISR
scheduled to expire at the timer's old time. The intended behavior is
that the clock's lower level timer should always be set to expire at the
time of the clocks head timer.

This patch changes ztimer_set() to call _ztimer_update(), which sets the
lower level timer according to the current list of timers, rather than
setting the timer directly inside of ztimer_set().
This commit is contained in:
Joshua DeWeese 2024-10-18 14:52:11 -04:00
parent 5b23bfb962
commit 45942f6821

View File

@ -193,15 +193,7 @@ uint32_t ztimer_set(ztimer_clock_t *clock, ztimer_t *timer, uint32_t val)
timer->base.offset = val; timer->base.offset = val;
_add_entry_to_list(clock, &timer->base); _add_entry_to_list(clock, &timer->base);
if (clock->list.next == &timer->base) { _ztimer_update(clock);
#ifdef MODULE_ZTIMER_EXTEND
if (clock->max_value < UINT32_MAX) {
val = _min_u32(val, clock->max_value >> 1);
}
DEBUG("ztimer_set(): %p setting %" PRIu32 "\n", (void *)clock, val);
#endif
clock->ops->set(clock, val);
}
irq_restore(state); irq_restore(state);