diff options
author | Dmitriy Vyukov <dvyukov@google.com> | 2014-07-16 12:19:33 +0400 |
---|---|---|
committer | Dmitriy Vyukov <dvyukov@google.com> | 2014-07-16 12:19:33 +0400 |
commit | bf4c887b9dd71d6f73b31ca531e7367fc64037e0 (patch) | |
tree | e18a60db91827a723866ed8adcb233e7d70e52a7 /src/pkg/runtime/proc.c | |
parent | bdcfd7e3eec342a0d468073e359429570208cc4f (diff) | |
download | go-bf4c887b9dd71d6f73b31ca531e7367fc64037e0.tar.gz |
runtime: start goroutine ids at 1
LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, khr
https://codereview.appspot.com/117810043
Diffstat (limited to 'src/pkg/runtime/proc.c')
-rw-r--r-- | src/pkg/runtime/proc.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c index 22ddce5bd..0b75415ac 100644 --- a/src/pkg/runtime/proc.c +++ b/src/pkg/runtime/proc.c @@ -1882,7 +1882,11 @@ runtime·newproc1(FuncVal *fn, byte *argp, int32 narg, int32 nret, void *callerp newg->gopc = (uintptr)callerpc; newg->status = Grunnable; if(p->goidcache == p->goidcacheend) { + // Sched.goidgen is the last allocated id, + // this batch must be [sched.goidgen+1, sched.goidgen+GoidCacheBatch]. + // At startup sched.goidgen=0, so main goroutine receives goid=1. p->goidcache = runtime·xadd64(&runtime·sched.goidgen, GoidCacheBatch); + p->goidcache -= GoidCacheBatch - 1; p->goidcacheend = p->goidcache + GoidCacheBatch; } newg->goid = p->goidcache++; |