From 909f31872a0e5e5b8ec5cc49b22ae661777a2fbc Mon Sep 17 00:00:00 2001 From: Dmitriy Vyukov Date: Tue, 12 Jul 2011 01:23:58 -0400 Subject: 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 --- src/pkg/runtime/runtime.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/pkg/runtime/runtime.c') 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; +} -- cgit v1.3-5-g9baa