From 95593758ba86cb7c19a171174bcb1a46848e5caf Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 12 Mar 2014 14:47:33 +0100 Subject: [PATCH] Add configuration parameter for contexts/guard_size. --- include/simgrid/simix.h | 2 ++ src/simgrid/sg_config.c | 14 ++++++++++++++ src/simix/smx_context.c | 2 ++ 3 files changed, 18 insertions(+) diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index da13e26b3b..02ef86dda6 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -168,6 +168,8 @@ 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; +extern int smx_context_guard_size; +extern int smx_context_guard_size_was_set; /* *********************** */ /* Context type definition */ diff --git a/src/simgrid/sg_config.c b/src/simgrid/sg_config.c index 64ebadd68e..fd2dfd2aa8 100644 --- a/src/simgrid/sg_config.c +++ b/src/simgrid/sg_config.c @@ -388,6 +388,12 @@ static void _sg_cfg_cb_context_stack_size(const char *name, int pos) smx_context_stack_size = xbt_cfg_get_int(_sg_cfg_set, name) * 1024; } +static void _sg_cfg_cb_context_guard_size(const char *name, int pos) +{ + smx_context_guard_size_was_set = 1; + smx_context_guard_size = xbt_cfg_get_int(_sg_cfg_set, name) * xbt_pagesize; +} + static void _sg_cfg_cb_contexts_nthreads(const char *name, int pos) { SIMIX_context_set_nthreads(xbt_cfg_get_int(_sg_cfg_set, name)); @@ -658,6 +664,14 @@ void sg_config_init(int *argc, char **argv) /* No, it was not set yet (the above setdefault() changed this to 1). */ smx_context_stack_size_was_set = 0; + /* guard size for contexts stacks in memory pages */ + xbt_cfg_register(&_sg_cfg_set, "contexts/guard_size", + "Guard size for contexts stacks in memory pages", + xbt_cfgelm_int, 1, 1, _sg_cfg_cb_context_guard_size, NULL); + xbt_cfg_setdefault_int(_sg_cfg_set, "contexts/guard_size", 1); + /* No, it was not set yet (the above setdefault() changed this to 1). */ + smx_context_guard_size_was_set = 0; + /* number of parallel threads for user processes */ xbt_cfg_register(&_sg_cfg_set, "contexts/nthreads", "Number of parallel threads used to execute user contexts", diff --git a/src/simix/smx_context.c b/src/simix/smx_context.c index 57d84e27e9..662f38288a 100644 --- a/src/simix/smx_context.c +++ b/src/simix/smx_context.c @@ -25,6 +25,8 @@ char* smx_context_factory_name = NULL; /* factory name specified by --cfg=contex smx_ctx_factory_initializer_t smx_factory_initializer_to_use = NULL; int smx_context_stack_size; int smx_context_stack_size_was_set = 0; +int smx_context_guard_size; +int smx_context_guard_size_was_set = 0; #ifdef HAVE_THREAD_LOCAL_STORAGE static __thread smx_context_t smx_current_context_parallel; #else -- 2.20.1