Skip to content

Conversation

jnohlgard
Copy link
Member

2015.09 release version of #3998

On a fast CPU with a slow timer (e.g. XTIMER_SHIFT > 0) it is possible
that now == _xtimer_now() when spinning for the overflow. In the extreme
case When this happens _next_period() will be called more than once
until the timer overflows for real.

Fault observed in real life when running on a 32.768 kHz timer on a
~96 MHz clocked mulle (Kinetis K60, Cortex-M4). _next_period() was
called 9 times during the same ISR call before the 32 kHz timer
overflowed.

On a fast CPU with a slow timer (e.g. XTIMER_SHIFT > 0) it is possible
that now == _xtimer_now() when spinning for the overflow. In the extreme
case When this happens _next_period() will be called more than once
until the timer overflows for real.

Fault observed in real life when running on a 32.768 kHz timer on a
~96 MHz clocked mulle (Kinetis K60, Cortex-M4). _next_period() was
called 9 times during the same ISR call before the 32 kHz timer
overflowed.
@jnohlgard jnohlgard added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Area: timers Area: timer subsystems labels Sep 30, 2015
@kaspar030
Copy link
Contributor

HAPPY 4000 everyone!! 🍻

@miri64
Copy link
Member

miri64 commented Sep 30, 2015

Change was ACK'd by @kaspar030 in #3998 already, so ACK here too.

miri64 added a commit that referenced this pull request Sep 30, 2015
…-2015.09

sys/xtimer: Avoid race incrementing multiple periods in _timer_callback
@miri64 miri64 merged commit 49181f4 into RIOT-OS:2015.09-branch Sep 30, 2015
@jnohlgard jnohlgard deleted the pr/xtimer-long-term-fast-cpu-bug-2015.09 branch September 30, 2015 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: timers Area: timer subsystems CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants