diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2013-02-21 16:24:38 +0400 |
|---|---|---|
| committer | Dmitriy Vyukov <dvyukov@google.com> | 2013-02-21 16:24:38 +0400 |
| commit | a0955a2aa2a2fcd5352f7e517c3f965e24fd8584 (patch) | |
| tree | 93c191c5b27a0367b42fdc86b9a7a3c414e18599 /src/pkg/runtime/thread_linux.c | |
| parent | c53fab969c31e3f15306a5b5b714928d2fd6b1df (diff) | |
| download | go-a0955a2aa2a2fcd5352f7e517c3f965e24fd8584.tar.xz | |
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
Diffstat (limited to 'src/pkg/runtime/thread_linux.c')
| -rw-r--r-- | src/pkg/runtime/thread_linux.c | 11 |
1 files changed, 9 insertions, 2 deletions
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)); } |
