Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
New: SIMIX_process_throw() allows to raise exceptions in remote processes
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 7 Aug 2014 00:03:42 +0000 (02:03 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 7 Aug 2014 08:58:56 +0000 (10:58 +0200)
ChangeLog
include/simgrid/simix.h
src/simix/smx_process.c

index 0c46ad1..f820250 100644 (file)
--- 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 <simgrid-devel@lists.gforge.inria.fr>
 
index 0af8212..e5c979a 100644 (file)
@@ -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);
index 77578ae..adf8d9d 100644 (file)
@@ -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);
 }