Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(108)

Unified Diff: src/pkg/runtime/proc.c

Issue 880043: code review 880043: runtime: fix bug in GOMAXPROCS when trying to cut numbe... (Closed)
Patch Set: code review 880043: runtime: two proc bug fixes Created 14 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/recover2.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/runtime/proc.c
===================================================================
--- a/src/pkg/runtime/proc.c
+++ b/src/pkg/runtime/proc.c
@@ -352,6 +352,10 @@
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 @@
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 @@
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();
« no previous file with comments | « no previous file | test/recover2.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b