X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5dc616d3c0127e742e4e8f6470aafbb7d789e6c1..37baaf70ee95c42a6f4b80913db243c199230fb9:/src/simix/smx_user.c diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 1f5f4b4f1a..a23bdda151 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -17,6 +17,7 @@ #include "smx_private.h" #include "mc/mc.h" +#include "xbt/ex.h" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix); @@ -342,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 @@ -350,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) { @@ -361,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; @@ -517,6 +521,24 @@ void simcall_process_set_data(smx_process_t process, void *data) } } +/** + * \brief Set the kill time of a process. + * + * \param process a process + * \param kill_time a double + */ +void simcall_process_set_kill_time(smx_process_t process, double kill_time) +{ + + if (kill_time > SIMIX_get_clock()) { + if (simix_global->kill_process_function) { + XBT_DEBUG("Set kill time %f for process %s(%s)",kill_time, process->name, + process->smx_host->name); + SIMIX_timer_set(kill_time, simix_global->kill_process_function, process); + } + } +} + /** * \brief Return the location on which an agent is running. * @@ -696,7 +718,7 @@ smx_action_t simcall_rdv_get_head(smx_rdv_t rdv) void simcall_comm_send(smx_rdv_t rdv, double task_size, double rate, void *src_buff, size_t src_buff_size, - int (*match_fun)(void *, void *), void *data, + int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout) { /* checking for infinite values */ @@ -731,7 +753,7 @@ void simcall_comm_send(smx_rdv_t rdv, double task_size, double rate, smx_action_t simcall_comm_isend(smx_rdv_t rdv, double task_size, double rate, void *src_buff, size_t src_buff_size, - int (*match_fun)(void *, void *), + int (*match_fun)(void *, void *, smx_action_t), void (*clean_fun)(void *), void *data, int detached) @@ -760,7 +782,7 @@ smx_action_t simcall_comm_isend(smx_rdv_t rdv, double task_size, double rate, } void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size, - int (*match_fun)(void *, void *), void *data, double timeout) + int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout) { xbt_assert(isfinite(timeout), "timeout is not finite!"); xbt_assert(rdv, "No rendez-vous point defined for recv"); @@ -787,7 +809,7 @@ void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size, } smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size, - int (*match_fun)(void *, void *), void *data) + int (*match_fun)(void *, void *, smx_action_t), void *data) { xbt_assert(rdv, "No rendez-vous point defined for irecv"); @@ -983,6 +1005,10 @@ int simcall_comm_is_latency_bounded(smx_action_t comm) smx_mutex_t simcall_mutex_init(void) { + if(!simix_global) { + fprintf(stderr,"You must run MSG_global_init or gras_init before using MSG or GRAS\n"); // I would have loved using xbt_die but I can't since it is not initialized yet... :) + abort(); + } smx_simcall_t simcall = SIMIX_simcall_mine(); simcall->call = SIMCALL_MUTEX_INIT;