[SeaBIOS] [PATCH v3 3/3] stacks: call check_irqs() after switch_next()

Volker Rümelin posted 3 patches 3 years, 3 months ago
There is a newer version of this series
[SeaBIOS] [PATCH v3 3/3] stacks: call check_irqs() after switch_next()
Posted by Volker Rümelin 3 years, 3 months ago
In function run_thread() the function check_irqs() gets called
after the thread switch for atomic handoff reasons. In yield()
it's the other way round.

If check_irqs() is called after run_thread() and check_irqs()
is called before switch_next() in yield(), it can happen in a
constructed case that a background thread runs twice without
a check_irqs() call in between. Call check_irqs() after
switch_next() in yield() to prevent this.

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
 src/stacks.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/stacks.c b/src/stacks.c
index 58c0317..e090919 100644
--- a/src/stacks.c
+++ b/src/stacks.c
@@ -630,12 +630,11 @@ yield(void)
         return;
     }
     struct thread_info *cur = getCurThread();
+    // Switch to the next thread
+    switch_next(cur);
     if (cur == &MainThread)
         // Permit irqs to fire
         check_irqs();
-
-    // Switch to the next thread
-    switch_next(cur);
 }
 
 void VISIBLE16
-- 
2.26.2

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org