From ab08960f6402f5c7cbb7b6e81694a60b6abed4c8 Mon Sep 17 00:00:00 2001 From: rsc Date: Thu, 27 Sep 2007 21:25:37 +0000 Subject: Final word on the locking fiasco? Change pushcli / popcli so that they can never turn on interrupts unexpectedly. That is, if interrupts are on, then pushcli(); popcli(); turns them off and back on, but if they are off to begin with, then pushcli(); popcli(); is a no-op. I think our fundamental mistake was having a primitive (release and then popcli nee spllo) that could turn interrupts on at unexpected moments instead of being explicit about when we want to start allowing interrupts. With the new semantics, all the manual fiddling of ncli to force interrupts off in certain sections goes away. In return, we must explicitly mark the places where we want to enable interrupts unconditionally, by calling sti(). There is only one: inside the scheduler loop. --- main.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index b489231..275aa80 100644 --- a/main.c +++ b/main.c @@ -12,19 +12,13 @@ static void mpmain(void) __attribute__((noreturn)); int main(void) { - int bcpu, i; extern char edata[], end[]; // clear BSS memset(edata, 0, end - edata); - // pushcli() every processor during bootstrap. - for(i=0; istack + KSTACKSIZE; + stack = kalloc(KSTACKSIZE); + *(void**)(code-4) = stack + KSTACKSIZE; *(void**)(code-8) = mpmain; lapic_startap(c->apicid, (uint)code); -- cgit v1.2.3