in various already expensive routines.
helps keep cpu utilization up when GOMAXPROCS > 1,
but not a full solution.
http://groups.google.com/group/golang-nuts/t/
7a9535c4136d3e2
R=r
CC=golang-dev
https://golang.org/cl/184043
SudoG *sg;
G* gp;
+ if(gcwaiting)
+ gosched();
+
if(debug) {
prints("chansend: chan=");
runtime·printpointer(c);
SudoG *sg;
G *gp;
+ if(gcwaiting)
+ gosched();
+
if(debug) {
prints("chanrecv: chan=");
runtime·printpointer(c);
G *gp;
byte *as;
+ if(gcwaiting)
+ gosched();
+
if(debug) {
prints("selectgo: sel=");
runtime·printpointer(sel);
SudoG *sg;
G* gp;
+ if(gcwaiting)
+ gosched();
+
lock(c);
incerr(c);
c->closed |= Wclosed;
{
byte *res;
+ if(gcwaiting)
+ gosched();
+
res = nil;
if(hash_lookup(h, ak, (void**)&res)) {
*pres = true;
byte *res;
int32 hit;
+ if(gcwaiting)
+ gosched();
+
res = nil;
if(av == nil) {
hash_remove(h, ak, (void**)&res);
void
runtime·mapiternext(struct hash_iter *it)
{
+ if(gcwaiting)
+ gosched();
+
it->data = hash_next(it);
if(debug) {
prints("runtime·mapiternext: iter=");
void *v;
uint32 *ref;
+ if(gcwaiting && g != m->g0)
+ gosched();
if(m->mallocing)
throw("malloc/free - deadlock");
m->mallocing = 1;
-
if(size == 0)
size = 1;
sweep();
mstats.next_gc = mstats.inuse_pages+mstats.inuse_pages*gcpercent/100;
}
- starttheworld();
m->gcing = 0;
semrelease(&gcsema);
+ starttheworld();
}
static int32 debug = 0;
+int32 gcwaiting;
+
// Go scheduler
//
// The go scheduler's job is to match ready-to-run goroutines (`g's)
stoptheworld(void)
{
lock(&sched);
+ gcwaiting = 1;
sched.mcpumax = 1;
while(sched.mcpu > 1) {
noteclear(&sched.stopped);
starttheworld(void)
{
lock(&sched);
+ gcwaiting = 0;
sched.mcpumax = sched.gomaxprocs;
matchmg();
unlock(&sched);
extern int32 panicking;
extern int32 maxround;
extern int32 fd; // usually 1; set to 2 when panicking
+extern int32 gcwaiting; // gc is waiting to run
int8* goos;
/*