Skip to content

xtimer: xtimer_set #4902

@malosek

Description

@malosek

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

Metadata

Metadata

Assignees

Labels

Area: timersArea: timer subsystemsType: bugThe issue reports a bug / The PR fixes a bug (including spelling errors)Type: questionThe issue poses a question regarding usage of RIOT

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions