From 91e92a2d3d40eaa9db59cd673229d3cbe90ef3dd Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Wed, 29 Dec 1999 15:44:59 +0000 Subject: Don't explicitly mmap() red zones at the bottom of thread stacks (except the initial thread). Instead, just leave an unmapped gap between thread stacks and make sure that the thread stacks won't grow into these gaps, simply by limiting the size of the stacks with the 'len' argument to mmap(). This (if I understand correctly) reduces VM overhead considerably. Reviewed by: deischen --- lib/libpthread/thread/thr_create.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'lib/libpthread/thread/thr_create.c') diff --git a/lib/libpthread/thread/thr_create.c b/lib/libpthread/thread/thr_create.c index a392cba477b0..fd9e7464a995 100644 --- a/lib/libpthread/thread/thr_create.c +++ b/lib/libpthread/thread/thr_create.c @@ -136,20 +136,11 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr, if (pthread_mutex_unlock(&_gc_mutex) != 0) PANIC("Cannot unlock gc mutex"); - /* Red zone: */ - if (mmap(stack - PTHREAD_STACK_GUARD, - PTHREAD_STACK_GUARD, 0, MAP_ANON, - -1, 0) == MAP_FAILED) { - ret = EAGAIN; - free(new_thread); - } /* Stack: */ - else if (mmap(stack, PTHREAD_STACK_DEFAULT, + if (mmap(stack, PTHREAD_STACK_DEFAULT, PROT_READ | PROT_WRITE, MAP_STACK, -1, 0) == MAP_FAILED) { ret = EAGAIN; - munmap(stack - PTHREAD_STACK_GUARD, - PTHREAD_STACK_GUARD); free(new_thread); } } -- cgit v1.2.3