]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: two proc bug fixes
authorRuss Cox <rsc@golang.org>
Tue, 6 Apr 2010 20:48:31 +0000 (13:48 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 6 Apr 2010 20:48:31 +0000 (13:48 -0700)
1. Fix bug in GOMAXPROCS when trying to cut number of procs
Race could happen on any system but was
manifesting only on Xen hosted Linux.

2. Fix recover on ARM, where FP != caller SP.

R=r
CC=golang-dev
https://golang.org/cl/880043

src/pkg/runtime/proc.c
test/recover2.go

index 8473cd26f57e262ded47265f7d8538cd1050e68e..454a4a2175bd4b0505d357981b53f878acc1af62 100644 (file)
@@ -352,6 +352,10 @@ stoptheworld(void)
        gcwaiting = 1;
        sched.mcpumax = 1;
        while(sched.mcpu > 1) {
+               // It would be unsafe for multiple threads to be using
+               // the stopped note at once, but there is only
+               // ever one thread doing garbage collection,
+               // so this is okay.
                noteclear(&sched.stopped);
                sched.waitstop = 1;
                unlock(&sched);
@@ -989,6 +993,8 @@ void
        Stktop *top, *oldtop;
        Panic *p;
 
+       fp = getcallersp(fp);
+
        // Must be a panic going on.
        if((p = g->panic) == nil || p->recovered)
                goto nomatch;
@@ -1113,13 +1119,14 @@ void
        lock(&sched);
        sched.gomaxprocs = n;
        sched.mcpumax = n;
-       // handle fewer procs
-       while(sched.mcpu > sched.mcpumax) {
-               noteclear(&sched.stopped);
-               sched.waitstop = 1;
+       // handle fewer procs?
+       if(sched.mcpu > sched.mcpumax) {
                unlock(&sched);
-               notesleep(&sched.stopped);
-               lock(&sched);
+               // just give up the cpu.
+               // we'll only get rescheduled once the
+               // number has come down.
+               gosched();
+               return;
        }
        // handle more procs
        matchmg();
index 96d591a15b560db1c937b9b5d6af9484f701524d..a6f75770c98ce462db0efe16584181086d4bc4f5 100644 (file)
@@ -15,6 +15,7 @@ package main
 import (
        "os"
        "strings"
+       "syscall"
 )
 
 var x = make([]byte, 10)
@@ -80,6 +81,10 @@ func test6() {
 }
 
 func test7() {
+       if syscall.ARCH == "arm" {
+               // ARM doesn't have floating point yet
+               return
+       }
        defer mustRecover("complex divide by zero")
        var x, y complex
        println(x / y)