From a0955a2aa2a2fcd5352f7e517c3f965e24fd8584 Mon Sep 17 00:00:00 2001 From: Dmitriy Vyukov Date: Thu, 21 Feb 2013 16:24:38 +0400 Subject: runtime: split minit() to mpreinit() and minit() mpreinit() is called on the parent thread and with mcache (can allocate memory), minit() is called on the child thread and can not allocate memory. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/7389043 --- src/pkg/runtime/thread_linux.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/pkg/runtime/thread_linux.c') diff --git a/src/pkg/runtime/thread_linux.c b/src/pkg/runtime/thread_linux.c index 02a5eaee2f..85c3e6b8cf 100644 --- a/src/pkg/runtime/thread_linux.c +++ b/src/pkg/runtime/thread_linux.c @@ -171,12 +171,19 @@ runtime·goenvs(void) } // Called to initialize a new m (including the bootstrap m). +// Called on the parent thread (main thread in case of bootstrap), can allocate memory. +void +runtime·mpreinit(M *mp) +{ + mp->gsignal = runtime·malg(32*1024); // OS X wants >=8K, Linux >=2K +} + +// Called to initialize a new m (including the bootstrap m). +// Called on the new thread, can not allocate memory. void runtime·minit(void) { // Initialize signal handling. - if(m->gsignal == nil) - m->gsignal = runtime·malg(32*1024); // OS X wants >=8K, Linux >=2K runtime·signalstack((byte*)m->gsignal->stackguard - StackGuard, 32*1024); runtime·rtsigprocmask(SIG_SETMASK, &sigset_none, nil, sizeof(Sigset)); } -- cgit v1.3