1
0
mirror of https://github.com/golang/go synced 2024-11-22 07:14:40 -07:00

undo CL 5844051 / 5d0322034aa8

Breaks closure test when GOMAXPROCS=2 or more.

««« original CL description
runtime: restore deadlock detection in the simplest case.

Fixes #3342.

R=iant, r, dave, rsc
CC=golang-dev, remy
https://golang.org/cl/5844051

»»»

R=rsc
CC=golang-dev
https://golang.org/cl/5924045
This commit is contained in:
Mikio Hara 2012-03-27 13:05:17 +09:00 committed by Russ Cox
parent a3498f4be4
commit 4c2614c57c
4 changed files with 5 additions and 33 deletions

View File

@ -358,9 +358,6 @@ runtime·MHeap_Scavenger(void)
h = &runtime·mheap; h = &runtime·mheap;
for(k=0;; k++) { for(k=0;; k++) {
// Return to the scheduler in case the rest of the world is deadlocked.
runtime·gosched();
runtime·noteclear(&note); runtime·noteclear(&note);
runtime·entersyscall(); runtime·entersyscall();
runtime·notetsleep(&note, tick); runtime·notetsleep(&note, tick);

View File

@ -521,16 +521,6 @@ mnextg(M *m, G *g)
} }
} }
// Check for a deadlock situation.
static void
checkdeadlock(void) {
if((scvg == nil && runtime·sched.grunning == 0) ||
(scvg != nil && runtime·sched.grunning == 1 && runtime·sched.gwait == 0 &&
(scvg->status == Grunnable || scvg->status == Grunning || scvg->status == Gsyscall))) {
runtime·throw("all goroutines are asleep - deadlock!");
}
}
// Get the next goroutine that m should run. // Get the next goroutine that m should run.
// Sched must be locked on entry, is unlocked on exit. // Sched must be locked on entry, is unlocked on exit.
// Makes sure that at most $GOMAXPROCS g's are // Makes sure that at most $GOMAXPROCS g's are
@ -580,9 +570,6 @@ top:
continue; continue;
} }
runtime·sched.grunning++; runtime·sched.grunning++;
// The work could actually have been the sole scavenger
// goroutine. Look for deadlock situation.
checkdeadlock();
schedunlock(); schedunlock();
return gp; return gp;
} }
@ -604,7 +591,11 @@ top:
} }
// Look for deadlock situation. // Look for deadlock situation.
checkdeadlock(); if((scvg == nil && runtime·sched.grunning == 0) ||
(scvg != nil && runtime·sched.grunning == 1 && runtime·sched.gwait == 0 &&
(scvg->status == Grunning || scvg->status == Gsyscall))) {
runtime·throw("all goroutines are asleep - deadlock!");
}
m->nextg = nil; m->nextg = nil;
m->waitnextg = 1; m->waitnextg = 1;

View File

@ -1,13 +0,0 @@
// $G $D/$F.go && $L $F.$A && ! ./$A.out || echo BUG: bug429
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Should print deadlock message, not hang.
package main
func main() {
select{}
}

View File

@ -15,9 +15,6 @@
== fixedbugs/ == fixedbugs/
=========== fixedbugs/bug429.go
throw: all goroutines are asleep - deadlock!
== bugs/ == bugs/
=========== bugs/bug395.go =========== bugs/bug395.go