Descriptionruntime: refactor routines for stopping, running goroutine from m
This CL adds 'dropg', which is called to drop the association
between m and its current goroutine, and it makes schedule
handle locked goroutines correctly, instead of requiring all
callers of schedule to do that.
The effect is that if you want to take over an m for, say,
garbage collection work while still allowing the current g
to run on some other m, you can do an mcall to a function
that is:
// dissociate gp
dropg();
gp->status = Gwaiting; // for ready
// put gp on run queue for others to find
runtime·ready(gp);
/* ... do other work here ... */
// done with m, let it run goroutines again
schedule();
Before this CL, the dropg() body had to be written explicitly,
and the check for lockedg before schedule had to be
written explicitly too, both of which make the code a bit
more fragile than it needs to be.
Patch Set 1 #Patch Set 2 : diff -r 6866fbf95095 https://code.google.com/p/go/ #Patch Set 3 : diff -r 6866fbf95095 https://code.google.com/p/go/ #Patch Set 4 : diff -r 6866fbf95095 https://code.google.com/p/go/ #Patch Set 5 : diff -r 29e283742de1 https://code.google.com/p/go/ #Patch Set 6 : diff -r 29e283742de1 https://code.google.com/p/go/ #MessagesTotal messages: 5
|