From fb214dc70aaeb7b4bbaf270bb9566843a0606933 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 20 Dec 2009 13:11:17 -0500 Subject: [PATCH] Fix yield() so it works from boot code. 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/stacks.c b/src/stacks.c index d237864..56d17a1 100644 --- a/src/stacks.c +++ b/src/stacks.c @@ -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 -- 2.25.1