Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cleanups: kill code dupplication
[simgrid.git] / src / msg / global.c
index 602ddc4..3ab2eca 100644 (file)
@@ -12,6 +12,7 @@
 #include "xbt/log.h"
 #include "xbt/virtu.h"
 #include "xbt/ex.h"            /* ex_backtrace_display */
+#include "mailbox.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_kernel, msg,
                                "Logging specific to MSG (kernel)");
@@ -43,7 +44,7 @@ void MSG_global_init_args(int *argc, char **argv)
  */
 void MSG_global_init(int *argc, char **argv)
 {
-  xbt_getpid = &MSG_process_self_PID;
+  xbt_getpid = MSG_process_self_PID;
   if (!msg_global) {
     SIMIX_global_init(argc, argv);
 
@@ -53,6 +54,13 @@ void MSG_global_init(int *argc, char **argv)
     msg_global->process_list = xbt_fifo_new();
     msg_global->max_channel = 0;
     msg_global->PID = 1;
+
+       /* initialization of the mailbox module */
+       MSG_mailbox_mod_init();
+
+    SIMIX_function_register_process_create(_MSG_process_create_from_SIMIX);
+    SIMIX_function_register_process_cleanup(__MSG_process_cleanup);
+    SIMIX_function_register_process_kill(_MSG_process_kill_from_SIMIX);
   }
   return;
 }
@@ -227,8 +235,15 @@ MSG_error_t MSG_clean(void)
   xbt_fifo_free(msg_global->process_list);
 
   free(msg_global);
+  msg_global = NULL;
+
+  /* cleanup all resources in the mailbox module */
+  MSG_mailbox_mod_exit();
+
   SIMIX_clean();
 
+  
+
   return MSG_OK;
 }