diff options
author | deischen <deischen@FreeBSD.org> | 2005-02-13 18:38:06 +0000 |
---|---|---|
committer | deischen <deischen@FreeBSD.org> | 2005-02-13 18:38:06 +0000 |
commit | b08240453920c3b01dccdfdcaf4ead51c8751139 (patch) | |
tree | 20b27889e6160d6fd92154986ae191b4512a1d3f /lib/libpthread | |
parent | 19a07769b7834a686b200b4794c15b3711867a2b (diff) | |
download | FreeBSD-src-b08240453920c3b01dccdfdcaf4ead51c8751139.zip FreeBSD-src-b08240453920c3b01dccdfdcaf4ead51c8751139.tar.gz |
Increase the default stacksizes:
32-bit 64-bit
main thread 2MB 4MB
other threads 1MB 2MB
Diffstat (limited to 'lib/libpthread')
-rw-r--r-- | lib/libpthread/thread/thr_attr_init.c | 1 | ||||
-rw-r--r-- | lib/libpthread/thread/thr_init.c | 14 | ||||
-rw-r--r-- | lib/libpthread/thread/thr_private.h | 10 | ||||
-rw-r--r-- | lib/libpthread/thread/thr_stack.c | 6 |
4 files changed, 22 insertions, 9 deletions
diff --git a/lib/libpthread/thread/thr_attr_init.c b/lib/libpthread/thread/thr_attr_init.c index 9c73463..604a1aa 100644 --- a/lib/libpthread/thread/thr_attr_init.c +++ b/lib/libpthread/thread/thr_attr_init.c @@ -54,6 +54,7 @@ _pthread_attr_init(pthread_attr_t *attr) memcpy(pattr, &_pthread_attr_default, sizeof(struct pthread_attr)); pattr->guardsize_attr = _thr_guard_default; + pattr->stacksize_attr = _thr_stack_default; /* Return a pointer to the attribute object: */ *attr = pattr; diff --git a/lib/libpthread/thread/thr_init.c b/lib/libpthread/thread/thr_init.c index 6d41087..3272365 100644 --- a/lib/libpthread/thread/thr_init.c +++ b/lib/libpthread/thread/thr_init.c @@ -337,7 +337,7 @@ init_main_thread(struct pthread *thread) * resource limits, so this stack needs an explicitly mapped * red zone to protect the thread stack that is just beyond. */ - if (mmap((void *)_usrstack - THR_STACK_INITIAL - + if (mmap((void *)_usrstack - _thr_stack_initial - _thr_guard_default, _thr_guard_default, 0, MAP_ANON, -1, 0) == MAP_FAILED) PANIC("Cannot allocate red zone for initial thread"); @@ -351,8 +351,8 @@ init_main_thread(struct pthread *thread) * actually free() it; it just puts it in the free * stack queue for later reuse. */ - thread->attr.stackaddr_attr = (void *)_usrstack - THR_STACK_INITIAL; - thread->attr.stacksize_attr = THR_STACK_INITIAL; + thread->attr.stackaddr_attr = (void *)_usrstack - _thr_stack_initial; + thread->attr.stacksize_attr = _thr_stack_initial; thread->attr.guardsize_attr = _thr_guard_default; thread->attr.flags |= THR_STACK_USER; @@ -427,6 +427,14 @@ init_private(void) _thr_page_size = getpagesize(); _thr_guard_default = _thr_page_size; + if (sizeof(void *) == 8) { + _thr_stack_default = THR_STACK64_DEFAULT; + _thr_stack_initial = THR_STACK64_INITIAL; + } + else { + _thr_stack_default = THR_STACK32_DEFAULT; + _thr_stack_initial = THR_STACK32_INITIAL; + } init_once = 1; /* Don't do this again. */ } else { /* diff --git a/lib/libpthread/thread/thr_private.h b/lib/libpthread/thread/thr_private.h index 9f9f505..c629038 100644 --- a/lib/libpthread/thread/thr_private.h +++ b/lib/libpthread/thread/thr_private.h @@ -466,14 +466,16 @@ struct pthread_attr { /* * Miscellaneous definitions. */ -#define THR_STACK_DEFAULT 65536 +#define THR_STACK32_DEFAULT (1 * 1024 * 1024) +#define THR_STACK64_DEFAULT (2 * 1024 * 1024) /* * 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. */ -#define THR_STACK_INITIAL 0x100000 +#define THR_STACK32_INITIAL (2 * 1024 * 1024) +#define THR_STACK64_INITIAL (4 * 1024 * 1024) /* * Define the different priority ranges. All applications have thread @@ -1034,7 +1036,7 @@ SCLASS struct pthread_attr _pthread_attr_default SCLASS_PRESET({ SCHED_RR, 0, TIMESLICE_USEC, THR_DEFAULT_PRIORITY, THR_CREATE_RUNNING, PTHREAD_CREATE_JOINABLE, NULL, - NULL, NULL, THR_STACK_DEFAULT, /* guardsize */0 + NULL, NULL, /* stacksize */0, /* guardsize */0 }); /* Default mutex attributes: */ @@ -1073,6 +1075,8 @@ SCLASS struct lock _rwlock_static_lock; SCLASS struct lock _keytable_lock; SCLASS struct lock _thread_list_lock; SCLASS int _thr_guard_default; +SCLASS int _thr_stack_default; +SCLASS int _thr_stack_initial; SCLASS int _thr_page_size; SCLASS pthread_t _thr_sig_daemon; SCLASS int _thr_debug_flags SCLASS_PRESET(0); diff --git a/lib/libpthread/thread/thr_stack.c b/lib/libpthread/thread/thr_stack.c index 484eb81..f634055 100644 --- a/lib/libpthread/thread/thr_stack.c +++ b/lib/libpthread/thread/thr_stack.c @@ -160,7 +160,7 @@ _thr_stack_alloc(struct pthread_attr *attr) * If the stack and guard sizes are default, try to allocate a stack * from the default-size stack cache: */ - if ((stacksize == THR_STACK_DEFAULT) && + if ((stacksize == _thr_stack_default) && (guardsize == _thr_guard_default)) { if ((spare_stack = LIST_FIRST(&dstackq)) != NULL) { /* Use the spare stack. */ @@ -191,7 +191,7 @@ _thr_stack_alloc(struct pthread_attr *attr) else { /* Allocate a stack from usrstack. */ if (last_stack == NULL) - last_stack = _usrstack - THR_STACK_INITIAL - + last_stack = _usrstack - _thr_stack_initial - _thr_guard_default; /* Allocate a new stack. */ @@ -245,7 +245,7 @@ _thr_stack_free(struct pthread_attr *attr) spare_stack->guardsize = round_up(attr->guardsize_attr); spare_stack->stackaddr = attr->stackaddr_attr; - if (spare_stack->stacksize == THR_STACK_DEFAULT && + if (spare_stack->stacksize == _thr_stack_default && spare_stack->guardsize == _thr_guard_default) { /* Default stack/guard size. */ LIST_INSERT_HEAD(&dstackq, spare_stack, qe); |