From 45e23bc4aac5ee8211a46b33bb79c7756f24439e Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Mon, 12 Nov 2012 14:33:50 +0100 Subject: [PATCH] avoid setting the value of the stack size for thread factory if the parameter is not explicitely set by the user (this is a bit annoying, as it adds a global to check the initialization, but it handles the case were the explicitely wanted value is also the default one) --- include/simgrid/simix.h | 1 + src/simix/smx_context.c | 2 +- src/simix/smx_context_thread.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 121b2ccc13..e12eb21665 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -161,6 +161,7 @@ typedef void (*smx_ctx_factory_initializer_t)(smx_context_factory_t*); XBT_PUBLIC(smx_ctx_factory_initializer_t) smx_factory_initializer_to_use; extern char* smx_context_factory_name; extern int smx_context_stack_size; +extern int smx_context_stack_size_was_set; #ifdef HAVE_THREAD_LOCAL_STORAGE extern __thread smx_context_t smx_current_context; diff --git a/src/simix/smx_context.c b/src/simix/smx_context.c index 9e1a961f35..0ce478fe81 100644 --- a/src/simix/smx_context.c +++ b/src/simix/smx_context.c @@ -19,7 +19,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_context, simix, char* smx_context_factory_name = NULL; /* factory name specified by --cfg=contexts/factory:value */ smx_ctx_factory_initializer_t smx_factory_initializer_to_use = NULL; int smx_context_stack_size = 128 * 1024; - +int smx_context_stack_size_was_set = 0; #ifdef HAVE_THREAD_LOCAL_STORAGE static __thread smx_context_t smx_current_context_parallel; #else diff --git a/src/simix/smx_context_thread.c b/src/simix/smx_context_thread.c index e29c655c15..98bc49e235 100644 --- a/src/simix/smx_context_thread.c +++ b/src/simix/smx_context_thread.c @@ -92,7 +92,7 @@ smx_ctx_thread_factory_create_context(xbt_main_func_t code, int argc, if (code) { context->begin = xbt_os_sem_init(0); context->end = xbt_os_sem_init(0); - xbt_os_thread_setstacksize(smx_context_stack_size); + if(smx_context_stack_size_was_set)xbt_os_thread_setstacksize(smx_context_stack_size); /* create and start the process */ /* NOTE: The first argument to xbt_os_thread_create used to be the process * -- 2.20.1