Skip to content

Commit 4844633

Browse files
Enoch247maribu
authored andcommitted
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(). (cherry picked from commit 45942f6)
1 parent c137ec8 commit 4844633

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

sys/ztimer/core.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,7 @@ uint32_t ztimer_set(ztimer_clock_t *clock, ztimer_t *timer, uint32_t val)
193193

194194
timer->base.offset = val;
195195
_add_entry_to_list(clock, &timer->base);
196-
if (clock->list.next == &timer->base) {
197-
#ifdef MODULE_ZTIMER_EXTEND
198-
if (clock->max_value < UINT32_MAX) {
199-
val = _min_u32(val, clock->max_value >> 1);
200-
}
201-
DEBUG("ztimer_set(): %p setting %" PRIu32 "\n", (void *)clock, val);
202-
#endif
203-
clock->ops->set(clock, val);
204-
}
196+
_ztimer_update(clock);
205197

206198
irq_restore(state);
207199

0 commit comments

Comments
 (0)