From: navarro Date: Fri, 27 Apr 2012 10:57:25 +0000 (+0200) Subject: Rewrite the kill_time mecanism. X-Git-Tag: v3_7~35^2~4 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/621e3b159443376a40ff174a1a30815bf265c0ac Rewrite the kill_time mecanism. --- diff --git a/examples/msg/start_kill_time/deployment_start_kill.xml b/examples/msg/start_kill_time/deployment_start_kill.xml index 474c99d177..4342a09516 100644 --- a/examples/msg/start_kill_time/deployment_start_kill.xml +++ b/examples/msg/start_kill_time/deployment_start_kill.xml @@ -2,9 +2,9 @@ - - - - - + + + + + \ No newline at end of file diff --git a/include/msg/msg.h b/include/msg/msg.h index 4dccee2737..4d3bc10a5a 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -100,6 +100,7 @@ XBT_PUBLIC(m_process_t) MSG_process_create_with_environment(const char code, void *data, m_host_t host, + double kill_time, int argc, char **argv, xbt_dict_t diff --git a/include/simix/datatypes.h b/include/simix/datatypes.h index b41e98944e..97e8af5ad8 100644 --- a/include/simix/datatypes.h +++ b/include/simix/datatypes.h @@ -88,6 +88,7 @@ typedef void (*smx_creation_func_t) ( /* process */ smx_process_t*, /* code */ xbt_main_func_t, /* userdata */ void*, /* hostname */ const char*, + /* kill_time */ double, /* argc */ int, /* argv */ char**, /* props */ xbt_dict_t); diff --git a/include/simix/simix.h b/include/simix/simix.h index 2de942e81d..59522ffd25 100644 --- a/include/simix/simix.h +++ b/include/simix/simix.h @@ -128,6 +128,7 @@ XBT_PUBLIC(void) simcall_process_create(smx_process_t *process, xbt_main_func_t code, void *data, const char *hostname, + double kill_time, int argc, char **argv, xbt_dict_t properties); diff --git a/src/gras/Virtu/sg_process.c b/src/gras/Virtu/sg_process.c index 44ca9d5bf2..b5244179d0 100644 --- a/src/gras/Virtu/sg_process.c +++ b/src/gras/Virtu/sg_process.c @@ -29,7 +29,7 @@ void gras_agent_spawn(const char *name, smx_process_t process; simcall_process_create(&process, name, code, NULL, - gras_os_myname(), argc, argv, properties); + gras_os_myname(), -1.0, argc, argv, properties); } /* ************************************************************************** diff --git a/src/msg/msg_private.h b/src/msg/msg_private.h index c43de1e82c..c9663621e7 100644 --- a/src/msg/msg_private.h +++ b/src/msg/msg_private.h @@ -133,7 +133,7 @@ void __MSG_display_process_status(void); void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc); void MSG_process_create_from_SIMIX(smx_process_t *process, const char *name, xbt_main_func_t code, void *data, - const char *hostname, int argc, + const char *hostname, double kill_time, int argc, char **argv, xbt_dict_t properties); void MSG_process_kill_from_SIMIX(smx_process_t p); void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, void* buff, size_t buff_size); diff --git a/src/msg/msg_process.c b/src/msg/msg_process.c index 43b782b53a..e8bf1b7202 100644 --- a/src/msg/msg_process.c +++ b/src/msg/msg_process.c @@ -58,12 +58,12 @@ void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc) /* This function creates a MSG process. It has the prototype enforced by SIMIX_function_register_process_create */ void MSG_process_create_from_SIMIX(smx_process_t* process, const char *name, xbt_main_func_t code, void *data, - const char *hostname, int argc, char **argv, + const char *hostname, double kill_time, int argc, char **argv, xbt_dict_t properties) { m_host_t host = MSG_get_host_by_name(hostname); m_process_t p = MSG_process_create_with_environment(name, code, data, - host, argc, argv, + host, kill_time, argc, argv, properties); *((m_process_t*) process) = p; } @@ -79,7 +79,7 @@ m_process_t MSG_process_create(const char *name, xbt_main_func_t code, void *data, m_host_t host) { - return MSG_process_create_with_environment(name, code, data, host, -1, + return MSG_process_create_with_environment(name, code, data, host, -1, -1, NULL, NULL); } @@ -113,7 +113,7 @@ m_process_t MSG_process_create_with_arguments(const char *name, void *data, m_host_t host, int argc, char **argv) { - return MSG_process_create_with_environment(name, code, data, host, + return MSG_process_create_with_environment(name, code, data, host, -1.0, argc, argv, NULL); } @@ -136,6 +136,7 @@ m_process_t MSG_process_create_with_arguments(const char *name, object. It is for user-level information and can be NULL. It can be retrieved with the function \ref MSG_process_get_data. * \param host the location where the new process is executed. + * \param kill_time the time when the process is killed. * \param argc first argument passed to \a code * \param argv second argument passed to \a code * \param properties list a properties defined for this process @@ -145,6 +146,7 @@ m_process_t MSG_process_create_with_arguments(const char *name, m_process_t MSG_process_create_with_environment(const char *name, xbt_main_func_t code, void *data, m_host_t host, + double kill_time, int argc, char **argv, xbt_dict_t properties) { @@ -174,7 +176,7 @@ m_process_t MSG_process_create_with_environment(const char *name, /* Let's create the process: SIMIX may decide to start it right now, * even before returning the flow control to us */ - simcall_process_create(&process, name, code, simdata, host->name, + simcall_process_create(&process, name, code, simdata, host->name, kill_time, argc, argv, properties); if (!process) { diff --git a/src/simix/smx_deployment.c b/src/simix/smx_deployment.c index 6c7d332644..d1cbbf6053 100644 --- a/src/simix/smx_deployment.c +++ b/src/simix/smx_deployment.c @@ -33,8 +33,8 @@ static void parse_process_init(void) parse_argv = xbt_new(char *, 2); parse_argv[0] = xbt_strdup(A_surfxml_process_function); parse_argc = 1; - start_time= surf_parse_get_double(A_surfxml_process_start_time); - kill_time = surf_parse_get_double(A_surfxml_process_kill_time); + start_time = surf_parse_get_double(A_surfxml_process_start_time); + kill_time = surf_parse_get_double(A_surfxml_process_kill_time); } static void parse_argument(void) @@ -48,6 +48,7 @@ static void parse_process_finalize(void) smx_process_arg_t arg = NULL; smx_process_t process = NULL; parse_argv[parse_argc] = NULL; + if (start_time > SIMIX_get_clock()) { arg = xbt_new0(s_smx_process_arg_t, 1); arg->name = parse_argv[0]; @@ -59,7 +60,7 @@ static void parse_process_finalize(void) arg->kill_time = kill_time; arg->properties = current_property_set; - XBT_DEBUG("Process %s(%s) will be started at time %f", arg->name, + XBT_INFO("Process %s(%s) will be started at time %f", arg->name, arg->hostname, start_time); SIMIX_timer_set(start_time, &SIMIX_process_create_from_wrapper, arg); } else { // start_time <= SIMIX_get_clock() @@ -68,22 +69,21 @@ static void parse_process_finalize(void) if (simix_global->create_process_function) simix_global->create_process_function(&process, parse_argv[0], - parse_code, NULL, - parse_host, parse_argc, + parse_code, + NULL, + parse_host, + kill_time, + parse_argc, parse_argv, current_property_set); else - simcall_process_create(&process, parse_argv[0], parse_code, NULL, parse_host, parse_argc, parse_argv, + simcall_process_create(&process, parse_argv[0], parse_code, NULL, parse_host, kill_time, parse_argc, parse_argv, current_property_set); + /* verify if process has been created (won't be the case if the host is currently dead, but that's fine) */ if (!process) { return; } - if (kill_time > SIMIX_get_clock()) { - if (simix_global->kill_process_function) { - SIMIX_timer_set(start_time, simix_global->kill_process_function, process); - } - } } current_property_set = NULL; } diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index 326f0ae87f..69105c9947 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -156,6 +156,7 @@ smx_process_t SIMIX_process_create_from_wrapper(smx_process_arg_t args) { args->code, args->data, args->hostname, + args->kill_time, args->argc, args->argv, args->properties); @@ -177,6 +178,7 @@ void SIMIX_process_create(smx_process_t *process, xbt_main_func_t code, void *data, const char *hostname, + double kill_time, int argc, char **argv, xbt_dict_t properties) { @@ -222,6 +224,14 @@ void SIMIX_process_create(smx_process_t *process, XBT_DEBUG("Inserting %s(%s) in the to_run list", (*process)->name, host->name); xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, *process); } + + if (kill_time > SIMIX_get_clock()) { + if (simix_global->kill_process_function) { + XBT_INFO("Process %s(%s) will be kill at time %f", (*process)->name, + (*process)->smx_host->name, kill_time); + SIMIX_timer_set(kill_time, simix_global->kill_process_function, *process); + } + } } /** @@ -253,7 +263,7 @@ void SIMIX_process_runall(void) */ void SIMIX_process_kill(smx_process_t process) { - XBT_DEBUG("Killing process %s on %s", process->name, process->smx_host->name); + XBT_INFO("Killing process %s on %s", process->name, process->smx_host->name); process->context->iwannadie = 1; process->blocked = 0; diff --git a/src/simix/smx_process_private.h b/src/simix/smx_process_private.h index 1099ccaa23..d5295c957d 100644 --- a/src/simix/smx_process_private.h +++ b/src/simix/smx_process_private.h @@ -50,6 +50,7 @@ void SIMIX_process_create(smx_process_t *process, xbt_main_func_t code, void *data, const char *hostname, + double kill_time, int argc, char **argv, xbt_dict_t properties); void SIMIX_process_runall(void); diff --git a/src/simix/smx_smurf.c b/src/simix/smx_smurf.c index df7fb256c9..c752587d3c 100644 --- a/src/simix/smx_smurf.c +++ b/src/simix/smx_smurf.c @@ -306,6 +306,7 @@ void SIMIX_simcall_pre(smx_simcall_t simcall, int value) simcall->process_create.code, simcall->process_create.data, simcall->process_create.hostname, + simcall->process_create.kill_time, simcall->process_create.argc, simcall->process_create.argv, simcall->process_create.properties); diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index a0888c152f..c16c605e9b 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -223,6 +223,7 @@ typedef struct s_smx_simcall { xbt_main_func_t code; void *data; const char *hostname; + double kill_time; int argc; char **argv; xbt_dict_t properties; diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 8c08f25690..2663088b9d 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -343,6 +343,7 @@ e_smx_state_t simcall_host_execution_wait(smx_action_t execution) * \param data a pointer to any data one may want to attach to the new object. It is for user-level information and can be NULL. * It can be retrieved with the function \ref simcall_process_get_data. * \param hostname name of the host where the new agent is executed. + * \param kill_time time when the process is killed * \param argc first argument passed to \a code * \param argv second argument passed to \a code * \param properties the properties of the process @@ -351,6 +352,7 @@ void simcall_process_create(smx_process_t *process, const char *name, xbt_main_func_t code, void *data, const char *hostname, + double kill_time, int argc, char **argv, xbt_dict_t properties) { @@ -362,6 +364,7 @@ void simcall_process_create(smx_process_t *process, const char *name, simcall->process_create.code = code; simcall->process_create.data = data; simcall->process_create.hostname = hostname; + simcall->process_create.kill_time = kill_time; simcall->process_create.argc = argc; simcall->process_create.argv = argv; simcall->process_create.properties = properties; diff --git a/src/xbt/xbt_sg_synchro.c b/src/xbt/xbt_sg_synchro.c index 34dba4a1cc..db92f6556a 100644 --- a/src/xbt/xbt_sg_synchro.c +++ b/src/xbt/xbt_sg_synchro.c @@ -66,7 +66,7 @@ xbt_thread_t xbt_thread_create(const char *name, void_f_pvoid_t code, /* char*name = bprintf("%s#%p",SIMIX_process_self_get_name(), param); */ simcall_process_create(&res->s_process, name, xbt_thread_create_wrapper, res, - SIMIX_host_self_get_name(), 0, NULL, + SIMIX_host_self_get_name(), -1.0, 0, NULL, /*props */ NULL); res->joinable = joinable; res->done = 0;