Skip to content

xtimer: xtimer_now() not ISR safe #5338

@kaspar030

Description

@kaspar030

On platforms where xtimer is using a <32bit counter, xtimer_now() might cause a wrong time to be returned when called from ISRs, as the _high_count and _long_count interrupts might be missed (delayed). This is also true for xtimer_now64() for all platforms, and also for all calls while IRQ's are disabled.

Unfortunately this also affects all xtimer_set*(), as they call xtimer_now[64}().

Can anyone think of an algorithm to prevent this?

(something like, a) set a flag after e.g., half the underlying timer's tick count, b) unset on overflow, and if in isr the tick count is < half and the flag is not set, add one to the long counter...)

Metadata

Metadata

Assignees

Labels

Area: timersArea: timer subsystemsType: bugThe issue reports a bug / The PR fixes a bug (including spelling errors)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions