diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2011-07-12 01:23:58 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2011-07-12 01:23:58 -0400 |
| commit | 909f31872a0e5e5b8ec5cc49b22ae661777a2fbc (patch) | |
| tree | 2dd9a44089d0aa91f6da86b81a439c7d007bbe35 /src/pkg/runtime/runtime.c | |
| parent | f9f21aa1fb45aaa4eece55f192783bfa46df4909 (diff) | |
| download | go-909f31872a0e5e5b8ec5cc49b22ae661777a2fbc.tar.xz | |
runtime: eliminate false sharing on random number generators
Use machine-local random number generator instead of
racy global ones.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4674049
Diffstat (limited to 'src/pkg/runtime/runtime.c')
| -rw-r--r-- | src/pkg/runtime/runtime.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/pkg/runtime/runtime.c b/src/pkg/runtime/runtime.c index 1a3653f108..83af8dc5e2 100644 --- a/src/pkg/runtime/runtime.c +++ b/src/pkg/runtime/runtime.c @@ -588,3 +588,16 @@ runtime·FuncForPC(uintptr pc, void *retf) retf = runtime·findfunc(pc); FLUSH(&retf); } + +uint32 +runtime·fastrand1(void) +{ + uint32 x; + + x = m->fastrand; + x += x; + if(x & 0x80000000L) + x ^= 0x88888eefUL; + m->fastrand = x; + return x; +} |
