]> Cypherpunks repositories - gostls13.git/commitdiff
keep a list of all the M's,
authorRuss Cox <rsc@golang.org>
Fri, 9 Oct 2009 22:35:33 +0000 (15:35 -0700)
committerRuss Cox <rsc@golang.org>
Fri, 9 Oct 2009 22:35:33 +0000 (15:35 -0700)
so that the garbage collector doesn't free them.

R=ken
OCL=35538
CL=35538

src/pkg/runtime/proc.c
src/pkg/runtime/runtime.h

index e3c7beccdf3eb16c4d594861b7ac26fe03d4d1af..f6f2bb2b3654170b2ba011f2660f16245393e3f0 100644 (file)
@@ -11,7 +11,6 @@ M     m0;
 G      g0;     // idle goroutine for m0
 
 static int32   debug   = 0;
-static Lock    debuglock;
 
 // Go scheduler
 //
@@ -96,6 +95,8 @@ schedinit(void)
 {
        int32 n;
        byte *p;
+       
+       allm = m;
 
        mallocinit();
        goargs();
@@ -416,6 +417,10 @@ matchmg(void)
                // Find the m that will run g.
                if((m = mget(g)) == nil){
                        m = malloc(sizeof(M));
+                       // Add to allm so garbage collector doesn't free m
+                       // when it is just in a register (R14 on amd64).
+                       m->alllink = allm;
+                       allm = m;
                        m->g0 = malg(8192);
                        m->id = sched.mcount++;
 
index d3027b9ce6b914ac99aee51e2eab16d3fcb00393..b44eb929ccc153cfb23fcbcb8a233310453d3e3c 100644 (file)
@@ -206,6 +206,7 @@ struct      M
        int32   waitnextg;
        Note    havenextg;
        G*      nextg;
+       M*      alllink;        // on allm
        M*      schedlink;
        Mem     mem;
        uint32  machport;       // Return address for Mach IPC (OS X)
@@ -307,6 +308,7 @@ struct Defer
 extern Alg     algarray[Amax];
 extern String  emptystring;
 G*     allg;
+M*     allm;
 int32  goidgen;
 extern int32   gomaxprocs;
 extern int32   panicking;