Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
global variables successfully moved into encapsulating structures.
[simgrid.git] / src / msg / m_process.c
index c75adcc..baf3316 100644 (file)
@@ -36,27 +36,37 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_process, msg, "Logging specific to MSG (proc
  * \sa MSG_process_create_with_arguments
  */
 m_process_t MSG_process_create(const char *name,
-                              m_process_code_t code, void *data,
+                              xbt_main_func_t code, void *data,
                               m_host_t host)
 {
   return MSG_process_create_with_arguments(name, code, data, host, -1, NULL);
 }
 
-static void MSG_process_cleanup(void *arg)
+void __MSG_process_cleanup(void *arg)
 {
        /* arg is a pointer to a simix process, we can get the msg process with the field data */
-       m_process_t proc = ((smx_process_t)arg)->data;
-  xbt_fifo_remove(msg_global->process_list, proc);
-       SIMIX_process_cleanup(arg);
-  free(proc->name);
-  proc->name = NULL;
-  free(proc->simdata);
-  proc->simdata = NULL;
-  free(proc);
-
-       return;
+   m_process_t proc = ((smx_process_t)arg)->data;
+   xbt_fifo_remove(msg_global->process_list, proc);
+   SIMIX_process_cleanup(arg);
+   free(proc->name);
+   proc->name = NULL;
+   free(proc->simdata);
+   proc->simdata = NULL;
+   free(proc);
+
+   return;
 }
 
+/* This function creates a MSG process. It has the prototype by SIMIX_function_register_process_create */
+void *_MSG_process_create_from_SIMIX(const char *name,
+                                    xbt_main_func_t code, void *data,
+                                    char * hostname, int argc, char **argv)
+{
+       m_host_t host = MSG_get_host_by_name(hostname);
+       return (void*)MSG_process_create_with_arguments(name,code,data,host,argc,argv);
+}
+
+
 /** \ingroup m_process_management
  * \brief Creates and runs a new #m_process_t.
 
@@ -82,18 +92,8 @@ static void MSG_process_cleanup(void *arg)
  * \return The new corresponding object.
  */
 
-
-
-m_process_t __MSG_process_create_with_arguments(const char *name,
-                                             m_process_code_t code, void *data,
-                                             char * hostname, int argc, char **argv)
-{
-       m_host_t host = MSG_get_host_by_name(hostname);
-       return MSG_process_create_with_arguments(name,code,data,host,argc,argv);
-}
-
 m_process_t MSG_process_create_with_arguments(const char *name,
-                                             m_process_code_t code, void *data,
+                                             xbt_main_func_t code, void *data,
                                              m_host_t host, int argc, char **argv)
 {
   simdata_process_t simdata = xbt_new0(s_simdata_process_t,1);
@@ -106,9 +106,8 @@ m_process_t MSG_process_create_with_arguments(const char *name,
   simdata->m_host = host;
   simdata->argc = argc;
   simdata->argv = argv;
-  simdata->s_process = SIMIX_process_create(name, (smx_process_code_t)code, 
-                                           (void*)process, host->name, argc, argv, 
-                                           MSG_process_cleanup );
+  simdata->s_process = SIMIX_process_create(name, code, 
+                                           (void*)process, host->name, argc, argv);
 
   if (SIMIX_process_self()) {
     simdata->PPID = MSG_process_get_PID(SIMIX_process_self()->data);
@@ -128,6 +127,11 @@ m_process_t MSG_process_create_with_arguments(const char *name,
   return process;
 }
 
+
+void _MSG_process_kill_from_SIMIX(void *p) {
+   MSG_process_kill((m_process_t)p);
+}
+
 /** \ingroup m_process_management
  * \param process poor victim
  *