Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
First bricks for auto_restart support in SIMIX/MSG.
[simgrid.git] / src / simix / smx_user.c
index 0987155..3ea1f92 100644 (file)
@@ -354,7 +354,8 @@ void simcall_process_create(smx_process_t *process, const char *name,
                               const char *hostname,
                               double kill_time,
                               int argc, char **argv,
-                              xbt_dict_t properties)
+                              xbt_dict_t properties,
+                              int auto_restart)
 {
   smx_simcall_t simcall = SIMIX_simcall_mine();
 
@@ -368,6 +369,7 @@ void simcall_process_create(smx_process_t *process, const char *name,
   simcall->process_create.argc = argc;
   simcall->process_create.argv = argv;
   simcall->process_create.properties = properties;
+  simcall->process_create.auto_restart = auto_restart;
   SIMIX_simcall_push(simcall->issuer);
 }
 
@@ -523,7 +525,6 @@ 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
  */
@@ -609,7 +610,34 @@ xbt_dict_t simcall_process_get_properties(smx_process_t process)
   SIMIX_simcall_push(simcall->issuer);
   return simcall->process_get_properties.result;
 }
+/**
+ * \brief Add an on_exit function
+ * Add an on_exit function which will be executed when the process exits/is killed.
+ */
+XBT_PUBLIC(void) simcall_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data) {
+  smx_simcall_t simcall = SIMIX_simcall_mine();
 
+  simcall->call = SIMCALL_PROCESS_ON_EXIT;
+  simcall->process_on_exit.process = process;
+  simcall->process_on_exit.fun = fun;
+  simcall->process_on_exit.data = data;
+
+  SIMIX_simcall_push(simcall->issuer);
+}
+/**
+ * \brief Sets the process to be auto-restarted or not by SIMIX when its host comes back up.
+ * Will restart the process when the host comes back up if auto_restart is set to 1.
+ */
+
+XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int auto_restart) {
+  smx_simcall_t simcall = SIMIX_simcall_mine();
+
+  simcall->call = SIMCALL_PROCESS_AUTO_RESTART_SET;
+  simcall->process_auto_restart.process = process;
+  simcall->process_auto_restart.auto_restart = auto_restart;
+
+  SIMIX_simcall_push(simcall->issuer);
+}
 /** \brief Creates a new sleep SIMIX action.
  *
  * This function creates a SURF action and allocates the data necessary
@@ -1006,7 +1034,7 @@ 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... :)
+    fprintf(stderr,"You must run MSG_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();
@@ -1203,7 +1231,7 @@ int simcall_sem_get_capacity(smx_sem_t sem)
   return simcall->sem_get_capacity.result;
 }
 
-size_t simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+double simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream)
 {
   smx_simcall_t simcall = SIMIX_simcall_mine();