notetsleepg is the same as notetsleep, but is called on user g.
It includes entersyscall/exitsyscall and will help to avoid
split stack functions in syscall status.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/
11681043
return ret;
// Wait for new log.
- runtime·entersyscallblock();
- runtime·notesleep(&p->wait);
- runtime·exitsyscall();
+ runtime·notetsleepg(&p->wait, -1);
runtime·noteclear(&p->wait);
n = p->handoff;
runtime·setprof(true);
return runtime·atomicload((uint32*)&n->key) != 0;
}
+
+bool
+runtime·notetsleepg(Note *n, int64 ns)
+{
+ bool res;
+
+ if(g == m->g0)
+ runtime·throw("notetsleepg on g0");
+ runtime·entersyscallblock();
+ res = runtime·notetsleep(n, ns);
+ runtime·exitsyscall();
+ return res;
+}
}
}
}
+
+bool
+runtime·notetsleepg(Note *n, int64 ns)
+{
+ bool res;
+
+ if(g == m->g0)
+ runtime·throw("notetsleepg on g0");
+ runtime·entersyscallblock();
+ res = runtime·notetsleep(n, ns);
+ runtime·exitsyscall();
+ return res;
+}
h = &runtime·mheap;
for(k=0;; k++) {
runtime·noteclear(¬e);
- runtime·entersyscallblock();
- runtime·notetsleep(¬e, tick);
- runtime·exitsyscall();
+ runtime·notetsleepg(¬e, tick);
runtime·lock(h);
now = runtime·nanotime();
runtime·noteclear(¬e);
notep = ¬e;
runtime·newproc1(&forcegchelperv, (byte*)¬ep, sizeof(notep), 0, runtime·MHeap_Scavenger);
- runtime·entersyscallblock();
- runtime·notesleep(¬e);
- runtime·exitsyscall();
+ runtime·notetsleepg(¬e, -1);
if(runtime·debug.gctrace > 0)
runtime·printf("scvg%d: GC forced\n", k);
runtime·lock(h);
* wake up early, it must wait to call noteclear until it
* can be sure that no other goroutine is calling
* notewakeup.
+ *
+ * notesleep/notetsleep are generally called on g0,
+ * notetsleepg is similar to notetsleep but is called on user g.
*/
void runtime·noteclear(Note*);
void runtime·notesleep(Note*);
void runtime·notewakeup(Note*);
bool runtime·notetsleep(Note*, int64); // false - timeout
+bool runtime·notetsleepg(Note*, int64); // false - timeout
/*
* low-level synchronization for implementing the above
new = HASWAITER;
if(runtime·cas(&sig.state, old, new)) {
if (new == HASWAITER) {
- runtime·entersyscallblock();
- runtime·notesleep(&sig);
- runtime·exitsyscall();
+ runtime·notetsleepg(&sig, -1);
runtime·noteclear(&sig);
}
break;
timers.sleeping = true;
runtime·noteclear(&timers.waitnote);
runtime·unlock(&timers);
- runtime·entersyscallblock();
- runtime·notetsleep(&timers.waitnote, delta);
- runtime·exitsyscall();
+ runtime·notetsleepg(&timers.waitnote, delta);
}
}