Commit be629138 authored by Russ Cox's avatar Russ Cox

use Note sched.stopped correctly

R=r
DELTA=6  (5 added, 0 deleted, 1 changed)
OCL=20777
CL=20779
parent 4d6bccb0
...@@ -59,6 +59,7 @@ struct Sched { ...@@ -59,6 +59,7 @@ struct Sched {
int32 predawn; // running initialization, don't run new gs. int32 predawn; // running initialization, don't run new gs.
Note stopped; // one g can wait here for ms to stop Note stopped; // one g can wait here for ms to stop
int32 waitstop; // after setting this flag
}; };
Sched sched; Sched sched;
...@@ -352,7 +353,10 @@ nextgandunlock(void) ...@@ -352,7 +353,10 @@ nextgandunlock(void)
throw("all goroutines are asleep - deadlock!"); throw("all goroutines are asleep - deadlock!");
m->nextg = nil; m->nextg = nil;
noteclear(&m->havenextg); noteclear(&m->havenextg);
if(sched.waitstop) {
sched.waitstop = 0;
notewakeup(&sched.stopped); notewakeup(&sched.stopped);
}
unlock(&sched); unlock(&sched);
notesleep(&m->havenextg); notesleep(&m->havenextg);
...@@ -376,6 +380,7 @@ stoptheworld(void) ...@@ -376,6 +380,7 @@ stoptheworld(void)
sched.mcpumax = 1; sched.mcpumax = 1;
while(sched.mcpu > 1) { while(sched.mcpu > 1) {
noteclear(&sched.stopped); noteclear(&sched.stopped);
sched.waitstop = 1;
unlock(&sched); unlock(&sched);
notesleep(&sched.stopped); notesleep(&sched.stopped);
lock(&sched); lock(&sched);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment