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 | aa76377423ac77d025284a6c11f0c874740202e8 (patch) | |
| tree | 294a42ddf9b725b31212d3439dadfb0c428b8e2a /src/pkg/runtime/proc.c | |
| parent | c12c5dba9c9d81242569f4108b707c6c16dfa066 (diff) | |
| download | go-aa76377423ac77d025284a6c11f0c874740202e8.tar.xz | |
runtime: start goroutine ids at 1
LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, khr
https://golang.org/cl/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 22ddce5bd4..0b75415aca 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++; |
