-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Hello,
still having some hypothetical issues with xtimer_set:
have single "blink" thread with endless loop which toggles the LED and calls
xtimer_set_wakeup(&xtimer, 500000, me);
thread_sleep();
which I believe is valid code.
in my hypothetical use case im calling
xtimer_set_wakeup with offset >= XTIMER_BACKOFF
this boils down to xtimer_set and hits the
uint32_t target = xtimer_now() + offset;
_xtimer_set_absolute(timer, target);
lets assume that xtimer_now is 0xFFFFFFFF
just after the target is loaded with 0xFFFFFFFF + offset, lets say 40,
now the timer IRQ comes and increases _long_cnt in _next_period, maybe scheduling some other thread...
after "blink" thread is resumed when timers are lets say 0x00000001 0x000000FF
now calling _xtimer_set_absolute with target 40
in xtimer set we are going with target < now condition which results in wrong timer->long_cnt value.
is it too hypothetical or it can really happen?
anyway there are two xtimer spins on the way, in xtimer_set and _xtimer_set_absolute - is it intentional?
or one more hypothetical case: xtimer_spin called when timers are 0x1 0xFFFFFFFF and offset lets say 39?
wbr
malo