Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/alpha/alpha Move call to sched_unlock_idle to later...



details:   https://anonhg.NetBSD.org/src/rev/b386d7b15bbb
branches:  trunk
changeset: 526297:b386d7b15bbb
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue Apr 30 16:05:13 2002 +0000

description:
Move call to sched_unlock_idle to later in the context switch to
eliminate a race where another processor could grab the outgoing
process before we were done saving our state into it, with predictable
results.

Bug spotted on i386 by Frank van der Linden <fvdl%wasabisystems.com@localhost>.

diffstat:

 sys/arch/alpha/alpha/locore.s |  23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diffs (51 lines):

diff -r 7f4af25b4cc1 -r b386d7b15bbb sys/arch/alpha/alpha/locore.s
--- a/sys/arch/alpha/alpha/locore.s     Tue Apr 30 15:37:33 2002 +0000
+++ b/sys/arch/alpha/alpha/locore.s     Tue Apr 30 16:05:13 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.98 2001/08/29 20:17:08 nathanw Exp $ */
+/* $NetBSD: locore.s,v 1.99 2002/04/30 16:05:13 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
 
 #include <machine/asm.h>
 
-__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.98 2001/08/29 20:17:08 nathanw Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.99 2002/04/30 16:05:13 thorpej Exp $");
 
 #include "assym.h"
 
@@ -828,13 +828,6 @@
 5:
        mov     t4, s2                          /* save new proc */
        ldq     s3, P_MD_PCBPADDR(s2)           /* save new pcbpaddr */
-#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
-       /*
-        * Done mucking with the run queues, release the
-        * scheduler lock, but keep interrupts out.
-        */
-       CALL(sched_unlock_idle)
-#endif
 
        /*
         * Check to see if we're switching to ourself.  If we are,
@@ -879,7 +872,17 @@
        mov     s3, a0                          /* swap the context */
        SWITCH_CONTEXT
 
-7:     /*
+7:
+#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
+       /*
+        * Done mucking with the run queues, and we have fully switched
+        * to the new process.  Release the scheduler lock, but keep
+        * interrupts out.
+        */
+       CALL(sched_unlock_idle)
+#endif
+
+       /*
         * Now that the switch is done, update curproc and other
         * globals.  We must do this even if switching to ourselves
         * because we might have re-entered cpu_switch() from idle(),



Home | Main Index | Thread Index | Old Index