[riot-notifications] [RIOT-OS/RIOT] core: `msg_receive()` sometimes returns without `msg` being re-set (#10881)

Kaspar Schleiser notifications at github.com
Mon Jan 28 16:28:46 CET 2019


>     * this doesn't seem to return, but rather ends up in `cpu_switch_context_exit()` which has the chance to run `sched_run` in `isr_cpu_switch_context_exit`, but for some reason it doesn't

Looks like, if an ISR (signal) occurs after ```thread_yield_higher``` has disabled them makes the called ```isr_thread_yield()``` jump into ```native_irq_handler()```, which calls ```sched_run()``` conditionally (on sched_context_switch_request), then jumps directly back to the user context. Seems like this can skip the ```sched_run()``` that the user context wanted to run.


Could you try this:

```
diff --git a/cpu/native/native_cpu.c b/cpu/native/native_cpu.c
index 2629e55df0..655562565e 100644
--- a/cpu/native/native_cpu.c
+++ b/cpu/native/native_cpu.c
@@ -208,6 +208,8 @@ void isr_thread_yield(void)
 
 void thread_yield_higher(void)
 {
+    sched_context_switch_request = 1;
+
     if (_native_in_isr == 0) {
         ucontext_t *ctx = (ucontext_t *)(sched_active_thread->sp);
         _native_in_isr = 1;
@@ -224,9 +226,6 @@ void thread_yield_higher(void)
         }
         irq_enable();
     }
-    else {
-        sched_context_switch_request = 1;
-    }
 }
 
 void native_cpu_init(void)
```

-- 
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/10881#issuecomment-458175779
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190128/18b5b405/attachment.html>


More information about the notifications mailing list