Fix yield() so it works from boot code.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 20 Dec 2009 18:11:17 +0000 (13:11 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 20 Dec 2009 18:11:17 +0000 (13:11 -0500)
In boot code, the f-segment is read-only, so make sure yield() doesn't
    rely on writes.
Easiest way to do this is to avoid stack switches when not needed.

src/stacks.c

index d2378646a3bb6358a20d8dd32fc0ab89147e9fd5..56d17a1ac8d396d0d321b4d6349f2ac48bdf8cbe 100644 (file)
@@ -50,7 +50,7 @@ call32(void *func)
         "  addl %0, %%esp\n"
         "  movl %%ss, %0\n"
 
-        // Transition to 32bit mode, call yield_preempt, return to 16bit
+        // Transition to 32bit mode, call func, return to 16bit
         "  pushl $(" __stringify(BUILD_BIOS_ADDR) " + 1f)\n"
         "  jmp transition32\n"
         "  .code32\n"
@@ -148,6 +148,9 @@ static void
 switch_next(struct thread_info *cur)
 {
     struct thread_info *next = cur->next;
+    if (cur == next)
+        // Nothing to do.
+        return;
     asm volatile(
         "  pushl $1f\n"                 // store return pc
         "  pushl %%ebp\n"               // backup %ebp