Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
msg_simix alpha. All functions implemented.
[simgrid.git] / src / simix / smx_process.c
index 5a5807b..18eb439 100644 (file)
@@ -32,18 +32,19 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_process, simix,
  */
 smx_process_t SIMIX_process_create(const char *name,
                               smx_process_code_t code, void *data,
-                              smx_host_t host)
+                              const char * hostname, void * clean_process_function)
 {
-  return SIMIX_process_create_with_arguments(name, code, data, host, -1, NULL);
+  return SIMIX_process_create_with_arguments(name, code, data, hostname, -1, NULL, clean_process_function);
 }
 
-static void SIMIX_process_cleanup(void *arg)
+void SIMIX_process_cleanup(void *arg)
 {
   xbt_swag_remove(arg, simix_global->process_list);
   xbt_swag_remove(arg, simix_global->process_to_run);
   xbt_swag_remove(arg, ((smx_process_t) arg)->simdata->host->simdata->process_list);
   free(((smx_process_t) arg)->name);
   ((smx_process_t) arg)->name = NULL;
+
   free(((smx_process_t) arg)->simdata);
   ((smx_process_t) arg)->simdata = NULL;
   free(arg);
@@ -75,11 +76,12 @@ static void SIMIX_process_cleanup(void *arg)
  */
 smx_process_t SIMIX_process_create_with_arguments(const char *name,
                                              smx_process_code_t code, void *data,
-                                             smx_host_t host, int argc, char **argv)
+                                             const char * hostname, int argc, char **argv, void * clean_process_function)
 {
-  simdata_process_t simdata = xbt_new0(s_simdata_process_t,1);
+  smx_simdata_process_t simdata = xbt_new0(s_smx_simdata_process_t,1);
   smx_process_t process = xbt_new0(s_smx_process_t,1);
   smx_process_t self = NULL;
+       smx_host_t host = SIMIX_host_get_by_name(hostname);
 
   xbt_assert0(((code != NULL) && (host != NULL)), "Invalid parameters");
   /* Simulator Data */
@@ -87,10 +89,16 @@ smx_process_t SIMIX_process_create_with_arguments(const char *name,
   simdata->host = host;
   simdata->argc = argc;
   simdata->argv = argv;
-  simdata->context = xbt_context_new(code, NULL, NULL, 
-                                    SIMIX_process_cleanup, process, 
-                                    simdata->argc, simdata->argv);
-
+       if (clean_process_function) {
+       simdata->context = xbt_context_new(code, NULL, NULL, 
+                                            clean_process_function, process, 
+                                            simdata->argc, simdata->argv);
+       }
+       else {
+       simdata->context = xbt_context_new(code, NULL, NULL, 
+                                            SIMIX_process_cleanup, process, 
+                                            simdata->argc, simdata->argv);
+       }
   //simdata->last_errno=SIMIX_OK;
 
 
@@ -114,6 +122,9 @@ smx_process_t SIMIX_process_create_with_arguments(const char *name,
   return process;
 }
 
+
+
+
 /** \ingroup m_process_management
  * \param process poor victim
  *
@@ -122,7 +133,7 @@ smx_process_t SIMIX_process_create_with_arguments(const char *name,
 void SIMIX_process_kill(smx_process_t process)
 {
   //int i;
-  simdata_process_t p_simdata = process->simdata;
+  smx_simdata_process_t p_simdata = process->simdata;
   //simdata_host_t h_simdata= p_simdata->host->simdata;
   //int _cursor;
   //smx_process_t proc = NULL;
@@ -244,7 +255,7 @@ smx_process_t SIMIX_process_self(void)
  */
 void SIMIX_process_suspend(smx_process_t process)
 {
-  simdata_process_t simdata = NULL;
+  smx_simdata_process_t simdata = NULL;
        
   xbt_assert0(((process) && (process->simdata)), "Invalid parameters");
 
@@ -300,7 +311,7 @@ void SIMIX_process_suspend(smx_process_t process)
  */
 void SIMIX_process_resume(smx_process_t process)
 {
-  simdata_process_t simdata = NULL;
+  smx_simdata_process_t simdata = NULL;
 
   xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters");
   CHECK_HOST();