]> xenbits.xensource.com Git - seabios.git/commitdiff
stacks: call check_irqs() after switch_next()
authorVolker Rümelin <vr_qemu@t-online.de>
Fri, 4 Jun 2021 18:01:20 +0000 (20:01 +0200)
committerKevin O'Connor <kevin@koconnor.net>
Wed, 9 Jun 2021 15:05:19 +0000 (11:05 -0400)
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

index df323259f137c0c8da16b2096a9898a2f4267125..4c8e5df68b49543cd5a8f55d778f3a51c80ccd48 100644 (file)
@@ -629,12 +629,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