-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sys: make xtimer isr-safe #5428
Conversation
I can test this on iotlab-m3 since my application seems to suffer from the bug. |
That would be nice, especially as the iotlab-m3 has 16bit timers... |
For easier reviewing, 7dc9ed2 contains the main changes, the rest is cosmetic. |
#include "debug.h" | ||
|
||
static volatile int _in_handler = 0; | ||
static int _in_handler = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not volatile anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use atomic_int_t
anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured it is only changed to one, possibly read, changed to zero within the handler ISR. Outside it is only read and then should always be zero. So volatile doesn't protect anything. More atomic access is not needed.
did you? ;) |
Oops, sorry, forgot, will do ASAP. |
|
I still have xtimer problems - with and without this patch, the result looks similar. I have a timer running that should tick every second, but the result looks like:
|
@OlegHahm Hm. Maybe I can take a look at your code? |
Sure you can, but it's a mess: https://github.com/OlegHahm/miniature-dangerzone/tree/master/ccnl_clustering I'm trying to create a simpler example that shows the problem. |
20160531-11.40.07.7307 m3-138.lille.iot-lab.info: cluster: SECOND: 46
Hmm. Could you add the xtimer_now() to the log statement, and sth like
|printf("%"PRIu32"\n", xtimer_now());| to where you set the timer message?
|
I'm trying. |
sample output:
|
Sometimes it's even worse:
|
I'm having issues with atmega timers and I merged this to see if it gets better, but I'm experiencing more unstability... especially on Actually it seems that Tested in arduino-mega2560 with |
Actually xtimer is too big for arduino-uno. We need to provide some kind of native access to timers for this platform...
|
Oh, I meant, test it on the arduino-mega2560. ;) Somehow xtimer works better for me. |
Oh yeah, I tested on mega2560 without this PR and it works well, and with a shift of 6 works even better, but |
@kaspar030, are these problems still existing? |
Yes, won't have time for this before the release. |
Wow, this PR got very outdated. Is still valid @kaspar030 ? |
if it fixes #4902, its worth reconsidering and working on |
@kaspar030 does this help fixing xtimer? Then it should have highest priority, I guess ... |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
I'll not be working on this, but concentrate on #11874. |
Nevertheless, this issue should be kept open as a note, until |
Obsoleted by #9530. |
I started making xtimer ISR-safe, ended up refactoring and simplifying a lot.
Changes:
Marked as API change as xtimer_usleep_until() now takes a 64bit state argument.
Marked WIP as it has only seen brief testing on native, samr21, msb-430h.
What do you think?
Fixes #4902.