OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "runtime.h" | 5 #include "runtime.h" |
6 #include "arch_GOARCH.h" | 6 #include "arch_GOARCH.h" |
7 #include "malloc.h" | 7 #include "malloc.h" |
8 #include "stack.h" | 8 #include "stack.h" |
9 #include "race.h" | 9 #include "race.h" |
10 #include "type.h" | 10 #include "type.h" |
(...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1934 G *gp; | 1934 G *gp; |
1935 P *p; | 1935 P *p; |
1936 | 1936 |
1937 old = runtime·gomaxprocs; | 1937 old = runtime·gomaxprocs; |
1938 if(old < 0 || old > MaxGomaxprocs || new <= 0 || new >MaxGomaxprocs) | 1938 if(old < 0 || old > MaxGomaxprocs || new <= 0 || new >MaxGomaxprocs) |
1939 runtime·throw("procresize: invalid arg"); | 1939 runtime·throw("procresize: invalid arg"); |
1940 // initialize new P's | 1940 // initialize new P's |
1941 for(i = 0; i < new; i++) { | 1941 for(i = 0; i < new; i++) { |
1942 p = runtime·allp[i]; | 1942 p = runtime·allp[i]; |
1943 if(p == nil) { | 1943 if(p == nil) { |
1944 » » » p = (P*)runtime·mallocgc(sizeof(*p), 0, 0, 1); | 1944 » » » p = (P*)runtime·mallocgc(sizeof(*p), 0, FlagNoInvokeGC); |
1945 p->status = Pgcstop; | 1945 p->status = Pgcstop; |
1946 runtime·atomicstorep(&runtime·allp[i], p); | 1946 runtime·atomicstorep(&runtime·allp[i], p); |
1947 } | 1947 } |
1948 if(p->mcache == nil) { | 1948 if(p->mcache == nil) { |
1949 if(old==0 && i==0) | 1949 if(old==0 && i==0) |
1950 p->mcache = m->mcache; // bootstrap | 1950 p->mcache = m->mcache; // bootstrap |
1951 else | 1951 else |
1952 p->mcache = runtime·allocmcache(); | 1952 p->mcache = runtime·allocmcache(); |
1953 } | 1953 } |
1954 if(p->runq == nil) { | 1954 if(p->runq == nil) { |
1955 p->runqsize = 128; | 1955 p->runqsize = 128; |
1956 » » » p->runq = (G**)runtime·mallocgc(p->runqsize*sizeof(G*),
0, 0, 1); | 1956 » » » p->runq = (G**)runtime·mallocgc(p->runqsize*sizeof(G*),
0, FlagNoInvokeGC); |
1957 } | 1957 } |
1958 } | 1958 } |
1959 | 1959 |
1960 // redistribute runnable G's evenly | 1960 // redistribute runnable G's evenly |
1961 for(i = 0; i < old; i++) { | 1961 for(i = 0; i < old; i++) { |
1962 p = runtime·allp[i]; | 1962 p = runtime·allp[i]; |
1963 while(gp = runqget(p)) | 1963 while(gp = runqget(p)) |
1964 globrunqput(gp); | 1964 globrunqput(gp); |
1965 } | 1965 } |
1966 // start at 1 because current M already executes some G and will acquire
allp[0] below, | 1966 // start at 1 because current M already executes some G and will acquire
allp[0] below, |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2540 bool | 2540 bool |
2541 runtime·topofstack(Func *f) | 2541 runtime·topofstack(Func *f) |
2542 { | 2542 { |
2543 return f->entry == (uintptr)runtime·goexit || | 2543 return f->entry == (uintptr)runtime·goexit || |
2544 f->entry == (uintptr)runtime·mstart || | 2544 f->entry == (uintptr)runtime·mstart || |
2545 f->entry == (uintptr)runtime·mcall || | 2545 f->entry == (uintptr)runtime·mcall || |
2546 f->entry == (uintptr)runtime·morestack || | 2546 f->entry == (uintptr)runtime·morestack || |
2547 f->entry == (uintptr)runtime·lessstack || | 2547 f->entry == (uintptr)runtime·lessstack || |
2548 f->entry == (uintptr)_rt0_go; | 2548 f->entry == (uintptr)_rt0_go; |
2549 } | 2549 } |
OLD | NEW |