[riot-notifications] [RIOT-OS/RIOT] fe310: Fix potential deadlock in thread_yield_higher (#15277)

nmeum notifications at github.com
Thu Jan 7 11:02:47 CET 2021


@nmeum commented on this pull request.



> @@ -180,8 +180,10 @@ void thread_yield_higher(void)
     /* Use SW intr to schedule context switch */
     CLINT_REG(CLINT_MSIP) = 1;
 
-    /* Latency of SW intr can be 4-7 cycles; wait for the SW intr */
-    __asm__ volatile ("wfi");
+    /* Latency of SW intr can be a few cycles; wait for the SW intr.
+     * We cannot use WFI here as the SW intr may be delivered before we
+     * reach the WFI instruction, thereby causing a thread deadlock. */
+    while (CLINT_REG(CLINT_MSIP) == 1) {};

Ping

-- 
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/pull/15277#discussion_r553227459
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210107/0cb74ccd/attachment.htm>


More information about the notifications mailing list