From: Martin Quinson Date: Thu, 7 Aug 2014 00:03:42 +0000 (+0200) Subject: New: SIMIX_process_throw() allows to raise exceptions in remote processes X-Git-Tag: v3_12~858^2~2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d636c31f9e9f75f9373fb7f4c2ffec35e66ee121 New: SIMIX_process_throw() allows to raise exceptions in remote processes --- diff --git a/ChangeLog b/ChangeLog index 0c46ad1a6f..f820250b94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ SimGrid (3.12) NOT RELEASED; urgency=low - (to complete) + SIMIX: + * New functions + - SIMIX_process_throw: raises an exception in a remote process + -- $date Da SimGrid team diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 0af82124a8..e5c979a37c 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -373,6 +373,8 @@ XBT_PUBLIC(void) simcall_process_create(smx_process_t *process, XBT_PUBLIC(void) simcall_process_kill(smx_process_t process); XBT_PUBLIC(void) simcall_process_killall(int reset_pid); +XBT_PUBLIC(void) SIMIX_process_throw(smx_process_t process, xbt_errcat_t cat, int value, const char *msg); + /* Process handling */ XBT_PUBLIC(void) simcall_process_cleanup(smx_process_t process); diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index 77578aef1b..adf8d9d4ed 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -332,7 +332,7 @@ void SIMIX_process_kill(smx_process_t process, smx_process_t issuer) { process->context->iwannadie = 1; process->blocked = 0; process->suspended = 0; - /* FIXME: set doexception to 0 also? */ + process->doexception = 0; /* destroy the blocking action if any */ if (process->waiting_action) { @@ -382,6 +382,64 @@ void SIMIX_process_kill(smx_process_t process, smx_process_t issuer) { } +/** @brief Ask another process to raise the given exception + * + * @param cat category of exception + * @param value value associated to the exception + * @param msg string information associated to the exception + */ +void SIMIX_process_throw(smx_process_t process, xbt_errcat_t cat, int value, const char *msg) { + SMX_EXCEPTION(process, cat, value, msg); + + if (process->suspended) + SIMIX_process_resume(process,SIMIX_process_self()); + + /* cancel the blocking action if any */ + if (process->waiting_action) { + + switch (process->waiting_action->type) { + + case SIMIX_ACTION_EXECUTE: + case SIMIX_ACTION_PARALLEL_EXECUTE: + SIMIX_host_execution_cancel(process->waiting_action); + break; + + case SIMIX_ACTION_COMMUNICATE: + xbt_fifo_remove(process->comms, process->waiting_action); + SIMIX_comm_cancel(process->waiting_action); + break; + + case SIMIX_ACTION_SLEEP: + SIMIX_process_sleep_destroy(process->waiting_action); + break; + + case SIMIX_ACTION_JOIN: + SIMIX_process_sleep_destroy(process->waiting_action); + break; + + case SIMIX_ACTION_SYNCHRO: + SIMIX_synchro_stop_waiting(process, &process->simcall); + break; + + case SIMIX_ACTION_IO: + SIMIX_io_destroy(process->waiting_action); + break; + + /* **************************************/ + /* TUTORIAL: New API */ + case SIMIX_ACTION_NEW_API: + SIMIX_new_api_destroy(process->waiting_action); + break; + /* **************************************/ + + } + } + process->waiting_action = NULL; + + if (!xbt_dynar_member(simix_global->process_to_run, &(process)) && process != SIMIX_process_self()) + xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, process); +} + void SIMIX_pre_process_killall(smx_simcall_t simcall, int reset_pid) { SIMIX_process_killall(simcall->issuer, reset_pid); }