From 05b79b2b34ad7d7b698c95b0247509ecca387e7d Mon Sep 17 00:00:00 2001 From: coldpeace Date: Wed, 21 Jul 2010 09:24:08 +0000 Subject: [PATCH] add SIMIX_process_set_function, could be used instead of parsing the deployment file git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8037 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/include/simix/simix.h | 6 ++++++ src/simix/smx_deployment.c | 41 +++++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/include/simix/simix.h b/src/include/simix/simix.h index 627101dd09..7faa5bc41f 100644 --- a/src/include/simix/simix.h +++ b/src/include/simix/simix.h @@ -27,6 +27,12 @@ XBT_PUBLIC(xbt_main_func_t) SIMIX_get_registered_function(const char *name); XBT_PUBLIC(void) SIMIX_launch_application(const char *file); +/* + * Deployment (Bypass the parser) + */ +XBT_PUBLIC(void) SIMIX_set_process_function(const char* process_host,const char *process_function,xbt_dynar_t arguments,double process_start_time,double process_kill_time); + + XBT_PUBLIC(double) SIMIX_get_clock(void); XBT_PUBLIC(void) SIMIX_init(void); XBT_PUBLIC(double) SIMIX_solve(xbt_fifo_t actions_done, diff --git a/src/simix/smx_deployment.c b/src/simix/smx_deployment.c index 31cd8fdb45..9e02cb26e2 100644 --- a/src/simix/smx_deployment.c +++ b/src/simix/smx_deployment.c @@ -175,10 +175,49 @@ void SIMIX_function_register_default(xbt_main_func_t code) */ xbt_main_func_t SIMIX_get_registered_function(const char *name) { - xbt_main_func_t res = NULL; + xbt_main_func_t res = NULL; xbt_assert0(simix_global, "SIMIX_global_init has to be called before SIMIX_get_registered_function."); res = xbt_dict_get_or_null(simix_global->registered_functions, name); return res ? res : default_function; } + + +/** + * \brief Bypass the parser, get arguments, and set function to each process + */ + +void SIMIX_process_set_function(const char* process_host,const char *process_function,xbt_dynar_t arguments,double process_start_time,double process_kill_time) +{ + unsigned int i; + char *arg; + + /* init process */ + parse_host = xbt_strdup(process_host); + xbt_assert1(SIMIX_host_get_by_name(parse_host), + "Host '%s' unknown", parse_host); + parse_code = SIMIX_get_registered_function(process_function); + xbt_assert1(parse_code, "Function '%s' unknown", + process_function); + parse_argc = 0; + parse_argv = NULL; + parse_argc++; + parse_argv = xbt_realloc(parse_argv, (parse_argc) * sizeof(char *)); + parse_argv[(parse_argc) - 1] = xbt_strdup(A_surfxml_process_function); + start_time = process_start_time; + kill_time = process_kill_time; + current_property_set = xbt_dict_new(); + + /* add arguments */ + xbt_dynar_foreach(arguments,i,arg) + { + parse_argc++; + parse_argv = xbt_realloc(parse_argv, (parse_argc) * sizeof(char *)); + parse_argv[(parse_argc) - 1] = xbt_strdup(arg); + } + + /*finalize */ + parse_process_finalize(); + +} -- 2.20.1