From 234dd7a6ba1a9783f43d500f8ee745b2f5b4db5a Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 5 Aug 2000 06:15:04 +0000 Subject: Update. * internals.h: Declare __pthread_max_stacksize. * pthread.c (__pthread_max_stacksize): New variable. (__pthread_initialize_manager): Determine __pthread_initialize_manager value. * manager.c (thread_segment): Return always NULL if FLOATING_STACKS. (pthread_allocate_stack): Allow kernel to choose stack address if FLOATING_STACKS. This also handles variable-sized stacks. Always allocate stack and guardoage together. Use mprotect to change guardpage access. * sysdeps/i386/useldt.h: Define FLOATING_STACKS and ARCH_STACK_MAX_SIZE. * attr.c (__pthread_attr_setstacksize): Also test value against upper limit. --- linuxthreads/pthread.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'linuxthreads/pthread.c') diff --git a/linuxthreads/pthread.c b/linuxthreads/pthread.c index d13923a821..514ba5b71f 100644 --- a/linuxthreads/pthread.c +++ b/linuxthreads/pthread.c @@ -182,6 +182,9 @@ char *__pthread_manager_thread_tos; int __pthread_exit_requested; int __pthread_exit_code; +/* Maximum stack size. */ +size_t __pthread_max_stacksize; + /* Nozero if the machine has more than one processor. */ int __pthread_smp_kernel; @@ -455,20 +458,32 @@ int __pthread_initialize_manager(void) struct rlimit limit; int max_stack; + getrlimit(RLIMIT_STACK, &limit); +#ifdef FLOATING_STACKS + if (limit.rlim_cur == RLIM_INFINITY) + limit.rlim_cur = ARCH_STACK_MAX_SIZE; +# ifdef NEED_SEPARATE_REGISTER_STACK + max_stack = limit.rlim_cur / 2; +# else + max_stack = limit.rlim_cur; +#endif + + __pthread_max_stacksize = max_stack; +#else /* Play with the stack size limit to make sure that no stack ever grows beyond STACK_SIZE minus one page (to act as a guard page). */ - getrlimit(RLIMIT_STACK, &limit); -#ifdef NEED_SEPARATE_REGISTER_STACK +# ifdef NEED_SEPARATE_REGISTER_STACK /* STACK_SIZE bytes hold both the main stack and register backing store. The rlimit value applies to each individually. */ - max_stack = STACK_SIZE/2 - __getpagesize(); -#else + max_stack = STACK_SIZE/2 - __getpagesize (); +# else max_stack = STACK_SIZE - __getpagesize(); -#endif +# endif if (limit.rlim_cur > max_stack) { limit.rlim_cur = max_stack; setrlimit(RLIMIT_STACK, &limit); } +#endif /* If basic initialization not done yet (e.g. we're called from a constructor run before our constructor), do it now */ if (__pthread_initial_thread_bos == NULL) pthread_initialize(); -- cgit v1.2.3