Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add MSG_vm_reboot
authorSamuel Lepetit <samuel.lepetit@inria.fr>
Wed, 4 Jul 2012 14:31:46 +0000 (16:31 +0200)
committerSamuel Lepetit <samuel.lepetit@inria.fr>
Wed, 4 Jul 2012 14:31:57 +0000 (16:31 +0200)
include/msg/msg.h
src/msg/msg_vm.c

index 843c881..192c44f 100644 (file)
@@ -340,6 +340,8 @@ XBT_PUBLIC(void) MSG_vm_resume(msg_vm_t vm);  // Simulate the fact of reading th
 
 XBT_PUBLIC(void) MSG_vm_shutdown(msg_vm_t vm); // killall
 
+XBT_PUBLIC(void) MSG_vm_reboot(msg_vm_t vm);
+
 XBT_PUBLIC(void) MSG_vm_destroy(msg_vm_t vm);
 
 XBT_PUBLIC(xbt_dynar_t) MSG_vms_as_dynar(void);
index 4b9e0ad..0dc2439 100644 (file)
@@ -157,7 +157,27 @@ void MSG_vm_shutdown(msg_vm_t vm)
     MSG_process_kill(process);
   }
 }
+/**
+ * \ingroup msg_VMs
+ * \brief Reboot the VM, restarting all the processes in it.
+ */
+void MSG_vm_reboot(msg_vm_t vm)
+{
+  xbt_dynar_t new_processes = xbt_dynar_new(sizeof(msg_process_t),NULL);
+
+  msg_process_t process;
+  unsigned int cpt;
 
+  xbt_dynar_foreach(vm->processes,cpt,process) {
+    msg_process_t new_process = MSG_process_restart(process);
+    xbt_dynar_push_as(new_processes,msg_process_t,new_process);
+
+  }
+
+  xbt_dynar_foreach(new_processes, cpt, process) {
+    MSG_vm_bind(vm,process);
+  }
+}
 /** @brief Destroy a msg_vm_t.
  *  @ingroup msg_VMs
  */