summaryrefslogtreecommitdiffstats
path: root/lib/libc_r
diff options
context:
space:
mode:
authormarcus <marcus@FreeBSD.org>2005-02-28 17:15:31 +0000
committermarcus <marcus@FreeBSD.org>2005-02-28 17:15:31 +0000
commit3bc669b0fc23485773f1fb98a7cfad823a34bf26 (patch)
tree3fdd1ce4aacb9c5b8f3732cdc071f0d2466f205b /lib/libc_r
parent6e3e336d4e8eeab836e05129e5d14567f1b6b9f0 (diff)
downloadFreeBSD-src-3bc669b0fc23485773f1fb98a7cfad823a34bf26.zip
FreeBSD-src-3bc669b0fc23485773f1fb98a7cfad823a34bf26.tar.gz
Increase the default stacksizes:
32-bit 64-bit main thread 2 MB 4 MB other threads 1 MB 2 MB Adapted from: libpthread Approved by: deischen
Diffstat (limited to 'lib/libc_r')
-rw-r--r--lib/libc_r/uthread/pthread_private.h21
-rw-r--r--lib/libc_r/uthread/uthread_init.c17
-rw-r--r--lib/libc_r/uthread/uthread_stack.c12
3 files changed, 30 insertions, 20 deletions
diff --git a/lib/libc_r/uthread/pthread_private.h b/lib/libc_r/uthread/pthread_private.h
index 0d49da1..8e74368 100644
--- a/lib/libc_r/uthread/pthread_private.h
+++ b/lib/libc_r/uthread/pthread_private.h
@@ -481,11 +481,9 @@ struct pthread_attr {
/*
* Miscellaneous definitions.
*/
-#if !defined(__ia64__)
-#define PTHREAD_STACK_DEFAULT 65536
-#else
-#define PTHREAD_STACK_DEFAULT 0x40000
-#endif
+#define PTHREAD_STACK32_DEFAULT (1 * 1024 * 1024)
+#define PTHREAD_STACK64_DEFAULT (2 * 1024 * 1024)
+
/*
* Size of default red zone at the end of each stack. In actuality, this "red
* zone" is merely an unmapped region, except in the case of the initial stack.
@@ -498,16 +496,17 @@ extern int _pthread_guard_default;
extern int _pthread_page_size;
+extern int _pthread_stack_default;
+
+extern int _pthread_stack_initial;
+
/*
* Maximum size of initial thread's stack. This perhaps deserves to be larger
* than the stacks of other threads, since many applications are likely to run
* almost entirely on this stack.
*/
-#if !defined(__ia64__)
-#define PTHREAD_STACK_INITIAL 0x100000
-#else
-#define PTHREAD_STACK_INITIAL 0x400000
-#endif
+#define PTHREAD_STACK32_INITIAL (2 * 1024 * 1024)
+#define PTHREAD_STACK64_INITIAL (4 * 1024 * 1024)
/*
* Define the different priority ranges. All applications have thread
@@ -1040,7 +1039,7 @@ SCLASS struct pthread_attr _pthread_attr_default
#ifdef GLOBAL_PTHREAD_PRIVATE
= { SCHED_RR, 0, TIMESLICE_USEC, PTHREAD_DEFAULT_PRIORITY,
PTHREAD_CREATE_RUNNING, PTHREAD_CREATE_JOINABLE, NULL, NULL, NULL,
- PTHREAD_STACK_DEFAULT, -1 };
+ -1, -1 };
#else
;
#endif
diff --git a/lib/libc_r/uthread/uthread_init.c b/lib/libc_r/uthread/uthread_init.c
index 1cd39b1..caed63f 100644
--- a/lib/libc_r/uthread/uthread_init.c
+++ b/lib/libc_r/uthread/uthread_init.c
@@ -194,6 +194,8 @@ static pthread_func_t jmp_table[][2] = {
int _pthread_guard_default;
int _pthread_page_size;
+int _pthread_stack_default;
+int _pthread_stack_initial;
/*
* Threaded process initialization
@@ -223,8 +225,17 @@ _thread_init(void)
_pthread_page_size = getpagesize();;
_pthread_guard_default = _pthread_page_size;
sched_stack_size = 4 * _pthread_page_size;
+ if (sizeof(void *) == 8) {
+ _pthread_stack_default = PTHREAD_STACK64_DEFAULT;
+ _pthread_stack_initial = PTHREAD_STACK64_INITIAL;
+ }
+ else {
+ _pthread_stack_default = PTHREAD_STACK32_DEFAULT;
+ _pthread_stack_initial = PTHREAD_STACK32_INITIAL;
+ }
_pthread_attr_default.guardsize_attr = _pthread_guard_default;
+ _pthread_attr_default.stacksize_attr = _pthread_stack_default;
/*
* Make gcc quiescent about {,libgcc_}references not being
@@ -361,17 +372,17 @@ _thread_init(void)
* this stack needs an explicitly mapped red zone to protect the
* thread stack that is just beyond.
*/
- if (mmap(_usrstack - PTHREAD_STACK_INITIAL -
+ if (mmap(_usrstack - _pthread_stack_initial -
_pthread_guard_default, _pthread_guard_default, 0,
MAP_ANON, -1, 0) == MAP_FAILED)
PANIC("Cannot allocate red zone for initial thread");
/* Set the main thread stack pointer. */
- _thread_initial->stack = _usrstack - PTHREAD_STACK_INITIAL;
+ _thread_initial->stack = _usrstack - _pthread_stack_initial;
/* Set the stack attributes: */
_thread_initial->attr.stackaddr_attr = _thread_initial->stack;
- _thread_initial->attr.stacksize_attr = PTHREAD_STACK_INITIAL;
+ _thread_initial->attr.stacksize_attr = _pthread_stack_initial;
/* Setup the context for the scheduler: */
_setjmp(_thread_kern_sched_jb);
diff --git a/lib/libc_r/uthread/uthread_stack.c b/lib/libc_r/uthread/uthread_stack.c
index b2f3f57..0b176ce 100644
--- a/lib/libc_r/uthread/uthread_stack.c
+++ b/lib/libc_r/uthread/uthread_stack.c
@@ -81,7 +81,7 @@ static LIST_HEAD(, stack) _mstackq = LIST_HEAD_INITIALIZER(_mstackq);
* | Red Zone (guard page) | red zone for 2nd thread
* | |
* +-----------------------------------+
- * | stack 2 - PTHREAD_STACK_DEFAULT | top of 2nd thread stack
+ * | stack 2 - _pthread_stack_default | top of 2nd thread stack
* | |
* | |
* | |
@@ -92,7 +92,7 @@ static LIST_HEAD(, stack) _mstackq = LIST_HEAD_INITIALIZER(_mstackq);
* | Red Zone | red zone for 1st thread
* | |
* +-----------------------------------+
- * | stack 1 - PTHREAD_STACK_DEFAULT | top of 1st thread stack
+ * | stack 1 - _pthread_stack_default | top of 1st thread stack
* | |
* | |
* | |
@@ -103,7 +103,7 @@ static LIST_HEAD(, stack) _mstackq = LIST_HEAD_INITIALIZER(_mstackq);
* | Red Zone |
* | | red zone for main thread
* +-----------------------------------+
- * | USRSTACK - PTHREAD_STACK_INITIAL | top of main thread stack
+ * | USRSTACK - _pthread_stack_initial | top of main thread stack
* | | ^
* | | |
* | | |
@@ -140,7 +140,7 @@ _thread_stack_alloc(size_t stacksize, size_t guardsize)
* If the stack and guard sizes are default, try to allocate a stack
* from the default-size stack cache:
*/
- if (stack_size == PTHREAD_STACK_DEFAULT &&
+ if (stack_size == _pthread_stack_default &&
guardsize == _pthread_guard_default) {
/*
* Use the garbage collector mutex for synchronization of the
@@ -190,7 +190,7 @@ _thread_stack_alloc(size_t stacksize, size_t guardsize)
if (stack == NULL) {
if (last_stack == NULL)
- last_stack = _usrstack - PTHREAD_STACK_INITIAL -
+ last_stack = _usrstack - _pthread_stack_initial -
_pthread_guard_default;
/* Allocate a new stack. */
@@ -231,7 +231,7 @@ _thread_stack_free(void *stack, size_t stacksize, size_t guardsize)
spare_stack->guardsize = guardsize;
spare_stack->stackaddr = stack;
- if (spare_stack->stacksize == PTHREAD_STACK_DEFAULT &&
+ if (spare_stack->stacksize == _pthread_stack_default &&
spare_stack->guardsize == _pthread_guard_default) {
/* Default stack/guard size. */
LIST_INSERT_HEAD(&_dstackq, spare_stack, qe);
OpenPOWER on IntegriCloud