-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
native: Resurect native/perif/timer and handle #715 (WIP) #3282
Conversation
There is still a very rare early random crash of hwtimer_wait() I will look at it. |
@@ -325,6 +385,7 @@ void native_isr_entry(int sig, siginfo_t *info, void *context) | |||
_native_cur_ctx = (ucontext_t *)sched_active_thread->sp; | |||
|
|||
DEBUG("\n\n\t\tnative_isr_entry: return to _native_sig_leave_tramp\n\n"); | |||
dINT(); |
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.
please use enableIRQ()
instead of the deprecated dINT
Nice one, pulling this into my network stack test branch prevents some ISR error messages at the least... Let us know once we can remove the WIP and test this in more depth! |
@benoit-canet Do you mind also fixing #2870? That periph timer implementation is basically using the same code, and I think you could adapt the fixes a lot quicker than me. |
@kaspar030 could #2870 be implemented on top of native hwtimers ? |
Ah ! I just saw you created RIOT. I think I will finish to polish hwtimer first by fixing corner case bugs in native. |
Just one idea: does it make sense to switch over to the |
Totally, as it would bring native closer to many other platforms, and get the periph/timer implementation some testing until we switch away from hwtimer/vtimer completely. |
That's what I wanted to hear :-) |
@benoit-canet hwtimer will be phased out soon, as we think the slimmer periph/timer interface coupled with a redesigned higher level interface is the way to go. #2870 is basically copy&paste from native hwtimer code to implement the periph/timer interface. It actually makes more sense to concentrate on stabilizing that. Compare #2926 to see where we're headed. |
Covered a few more corner cases that could cause hwtimer_wait stall. There is still a rare intermitent crash but I think it related on how context switchs are done I test with: --#!/bin/bash make clean all-debug while : screen -d -m -L gdb -ex 'run > log' ./bin/native/hwtimer_wait.elf success=$(cat log|grep success) if [ "$success" != "success" ] pkill screen done |
@kaspar030 I'll look a these issues/PR. |
@kaspar030 I resurected your perif/timer series an rebased it in top of my patches. |
Why the idle_thread never try to thread_yield_higher ? What if it's stuck in lpm's pause and the signal that wake it up does not reschedule something else ? |
In RIOT, a thread is always run if there's no higher thread waiting to be run. CPU time is never time-sliced between multiple running threads, the scheduler is completely tickless.
Interrupts are supposed to trigger the scheduler, i.e., by setting "sched_context_switch_request = 1", if another thread might need scheduling. So if idle goes to LPM, then an interrupt occurs, and another thread needs to be run, the scheduler would switch to this other thread, and only if this other thread (and all others) are finished, switch back to the idle thread. |
@kaspar030 thanks for the clear explanation. |
@kaspar030 work fine on two machines now up for review |
I don't have access to an osX machine for testing though. |
@benoit-canet I've tried the ng_networking example. It loses some packets (compared to master, which loses none). Also, when I hammer it with pings from the linux box, it crashes at some point:
master works fine (unless two packets arrive at the same time). edit that was on Linux. |
The trampoline removal is the culprit. I'll try without it. |
@kaspar030 Everything seems to work fine without the trampoline related commits. I will run the hwtimer_wait test a few hours and if it work I'll postpone my no assembly crusade for later ;) |
@kaspar030 works fine now including the ping6 -f test. |
It doesn't always freeze... |
Enabling debug in timer.c and hwtimer.c makes it freeze a lot less. ;( |
The problem is vtimer setting an absolute timeout in the past. |
In that case the problem shouldn't be related to OSX right? tests/vtimer_msg works for me. Is that still the misbehaving application you're talking about? |
No, it's not vtimer. Seems like using "timer_set_absolute()" with very small offsets causes timer.c to underflow, e.g., set a hwtimer in the past. |
@kaspar030 that what NATIVE_TIMER_MIN_RES is suposed to prevent |
@kaspar030 but increasing it will slow down test/hwtimer_wait test further |
@benoit-canet with |
@thomaseichinger Could you test this ? http://paste.debian.net/280649/ |
@thomaseichinger and this http://paste.debian.net/280657/ to test @kaspar030 hypothesis |
@kaspar030 Does #3147 help with the vtimer issue? |
[1] http://paste.debian.net/280649/ |
Same here (didn't try [3]). |
[2] doesn't fix anything, delta calculation needs to be cast to (int32_t) to actually get a negative value. |
[2] should be delta <= 0 also to avoid cancelling the timer. |
@kaspar030 is it expected from the upper layer that setting a relative timer to 0 does a cancel ? Or should we rework timer.c ? |
@benoit-canet No, setting to absolute 0 shouldn't cancel. |
Ok I'l prepare a series |
I have a weird effect. If catching underflows like this:
When the underflow happens, the test seems to delay exactly the amount of time timer_read() would return. edit nevermind, I see it... |
Can't we just replace this call by |
wtimer also uses it, it's needed there to e.g., set a timer exactly to overflow. But wtimer checks a lot better for underflows. |
@benoit-canet I have a patch ready to prevent the underflow. |
See #3344. Together with [1], this makes the test run fine for me. |
@kaspar030 I did a pr for the zero value case |
alright, @thomaseichinger, could you confirm that master + #3344 works for you? |
@kaspar030 any idea for the slowliness of the hwtimer_wait test case on native ? Should we define the idea of a minimal timer resolution in a central place and bake it in the hwtimer_wait/main.c loop test ? |
@kaspar030 didn't see any freezes with #3344. |
@benoit-canet I stopped following your debugging steps here and in the other PRs so I can't comment in detail. In general I'd like to have an application that does what it says :-). If this is dependent on general timer specifications (like granularity), a global macro and a comment about the behaviour seem to be reasonable. |
-An eINT() was missing before calling the trampoline.
-A potential dINT()/eINT() recursive call has been eliminated.
-schedule_timer() was setting the native timer while signals where disabled this could leads to SIGALARM being blocked.
-Add a define for the native platform timer resolution
-A bunch of case in the signal handler where mishandled leading to usefull signal being not processed.So a mechanism to postpone the processing of these usefull signals was added.
Pass the hwtimer* and vtimer* tests.