From a0b3dffc3d8f4c9f62816004946bf6c95f9f9971 Mon Sep 17 00:00:00 2001 From: jasone 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/libc_r/uthread/uthread_init.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/libc_r/uthread/uthread_init.c') diff --git a/lib/libc_r/uthread/uthread_init.c b/lib/libc_r/uthread/uthread_init.c index c888697..051483f 100644 --- a/lib/libc_r/uthread/uthread_init.c +++ b/lib/libc_r/uthread/uthread_init.c @@ -186,7 +186,13 @@ _thread_init(void) /* Initialize the thread stack cache: */ SLIST_INIT(&_stackq); - /* Create the red zone for the main stack. */ + /* + * Create a red zone below the main stack. All other stacks are + * constrained to a maximum size by the paramters passed to + * mmap(), but this stack is only limited by resource limits, so + * this stack needs an explicitly mapped red zone to protect the + * thread stack that is just beyond. + */ if (mmap((void *) USRSTACK - PTHREAD_STACK_INITIAL - PTHREAD_STACK_GUARD, PTHREAD_STACK_GUARD, 0, MAP_ANON, -1, 0) == MAP_FAILED) -- cgit v1.1