]> Cypherpunks repositories - gostls13.git/commit
runtime: refactor routines for stopping, running goroutine from m
authorRuss Cox <rsc@golang.org>
Tue, 15 Jul 2014 00:56:37 +0000 (20:56 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 15 Jul 2014 00:56:37 +0000 (20:56 -0400)
commit64c2083ebc4a071f842368154c77601e9463f5d5
tree583511e95fffac7a9c10d98055de501a34f4f311
parentd3a2f5870034db2d69bd0ef85f18a87f4163c770
runtime: 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.

LGTM=iant
R=dvyukov, iant
CC=golang-codereviews, rlh
https://golang.org/cl/113110043
src/pkg/runtime/proc.c