[riot-notifications] [RIOT-OS/RIOT] xtimer: xtimer_now() not ISR safe (#5338)

Gaƫtan Harter notifications at github.com
Tue Jun 18 18:09:33 CEST 2019


It can fail from both interrupts and masked interrupts. Even reading time from an xtimer callback can fail.

For me this is the first thing to solve. Other issues with concurrency issues checking `XTIMER_BACKOFF` cannot work if you cannot rely on reading time from masked interrupt context.

https://github.com/RIOT-OS/RIOT/issues/5338#issuecomment-211820408 is indeed a  way of handling it.

Another solution I imagine, would be to save the previous last time that was read and adjust the time returned by `xtimer_now` and `xtimer_now64` to be sure it is not in the past. It should be updated once per period at least by the xtimer interrupt so would be detectable.

There is a maximum time that interrupt should be allowed to be masked anyway.
If it is more than a cycle, it cannot be detected. With half a cycle it should be able to work.

Note that there is already a usage that reads from masked interrupt and it fails for `arduino-mega2560` 
https://github.com/RIOT-OS/RIOT/pull/8040
https://github.com/RIOT-OS/Release-Specs/issues/98


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/issues/5338#issuecomment-503204364
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190618/b7b81136/attachment.html>


More information about the notifications mailing list