Skip to content
Snippets Groups Projects
Commit ee622cc1 authored by Damien George's avatar Damien George
Browse files

unix/mpthreadport: Adjust minimum thread stack, and stack limit check.

The minimum thread stack size is set by pthreads (16k bytes) so we must
use that value for our minimum.  The stack limit check is also adjusted
to work correctly for 32-bit builds.
parent 26d5e91b
No related branches found
No related tags found
No related merge requests found
......@@ -134,11 +134,14 @@ void mp_thread_start(void) {
}
void mp_thread_create(void *(*entry)(void*), void *arg, size_t *stack_size) {
// default stack size is 8k machine-words, minimum is 2k
// default stack size is 8k machine-words
if (*stack_size == 0) {
*stack_size = 8192 * BYTES_PER_WORD;
} else if (*stack_size < 2048 * BYTES_PER_WORD) {
*stack_size = 2048 * BYTES_PER_WORD;
}
// minimum stack size is set by pthreads
if (*stack_size < PTHREAD_STACK_MIN) {
*stack_size = PTHREAD_STACK_MIN;
}
// set thread attributes
......@@ -163,7 +166,8 @@ void mp_thread_create(void *(*entry)(void*), void *arg, size_t *stack_size) {
}
// adjust stack_size to provide room to recover from hitting the limit
*stack_size -= 1024 * BYTES_PER_WORD;
// this value seems to be about right for both 32-bit and 64-bit builds
*stack_size -= 8192;
// add thread to linked list of all threads
thread_t *th = malloc(sizeof(thread_t));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment