diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-08-05 06:15:04 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-08-05 06:15:04 +0000 |
commit | 234dd7a6ba1a9783f43d500f8ee745b2f5b4db5a (patch) | |
tree | 7b78bb63ef3d2c1ebfc89b59759068f2e394df5c /linuxthreads/pthread.c | |
parent | 0a8d92310f5c5e0c09c8ff9a79ac652a66d5b3da (diff) | |
download | glibc-234dd7a6ba1a9783f43d500f8ee745b2f5b4db5a.tar.gz glibc-234dd7a6ba1a9783f43d500f8ee745b2f5b4db5a.tar.xz glibc-234dd7a6ba1a9783f43d500f8ee745b2f5b4db5a.zip |
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.
Diffstat (limited to 'linuxthreads/pthread.c')
-rw-r--r-- | linuxthreads/pthread.c | 25 |
1 files changed, 20 insertions, 5 deletions
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(); |