Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Clean up actions when a condition is destroyed.
[simgrid.git] / src / simix / smx_process.c
index 9b9fc84..8577616 100644 (file)
@@ -51,8 +51,7 @@ void SIMIX_process_cleanup(void *arg)
  */
 smx_process_t SIMIX_process_create(const char *name,
                                   xbt_main_func_t code, void *data,
-                                  const char * hostname, int argc, char **argv, 
-                                  void * clean_process_function)
+                                  const char * hostname, int argc, char **argv)
 {
   smx_simdata_process_t simdata = xbt_new0(s_smx_simdata_process_t,1);
   smx_process_t process = xbt_new0(s_smx_process_t,1);
@@ -67,16 +66,9 @@ smx_process_t SIMIX_process_create(const char *name,
        simdata->cond = NULL;
   simdata->argc = argc;
   simdata->argv = 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->context = xbt_context_new(code, NULL, NULL, 
+                                    simix_global->cleanup_process_function, process, 
+                                    simdata->argc, simdata->argv);
 
   /* Process structure */
   process->name = xbt_strdup(name);
@@ -107,7 +99,6 @@ smx_process_t SIMIX_process_create(const char *name,
 void SIMIX_jprocess_create(const char *name, smx_host_t host,
                           void *data,
                           void *jprocess, void *jenv,
-                          void *clean_process_function,
                           smx_process_t *res)
 {
   smx_simdata_process_t simdata = xbt_new0(s_smx_simdata_process_t,1);
@@ -139,15 +130,9 @@ void SIMIX_jprocess_create(const char *name, smx_host_t host,
   simdata->argc = 0;
   simdata->argv = NULL;
   
-   if (clean_process_function) {
-      simdata->context = xbt_context_new(NULL, NULL, NULL, 
-                                        clean_process_function, process, 
-                                        /* argc/argv*/0,NULL);
-   } else {
-      simdata->context = xbt_context_new(NULL, NULL, NULL, 
-                                        SIMIX_process_cleanup, process, 
-                                        /* argc/argv*/0,NULL);
-   }
+  simdata->context = xbt_context_new(NULL, NULL, NULL, 
+                                    simix_global->cleanup_process_function, process, 
+                                    /* argc/argv*/0,NULL);
 
   /* Process structure */
   process->name = xbt_strdup(name);
@@ -184,20 +169,28 @@ void SIMIX_process_kill(smx_process_t process)
    DEBUG2("Killing process %s on %s",process->name, p_simdata->s_host->name);
   
    /* Cleanup if we were waiting for something */
+   DEBUG0("Here!");
    if (p_simdata->mutex) 
       xbt_swag_remove(process,p_simdata->mutex->sleeping);
    
+   DEBUG0("Here!");
    if (p_simdata->cond) 
       xbt_swag_remove(process,p_simdata->cond->sleeping);
 
+   DEBUG0("Here!");
    xbt_swag_remove(process, simix_global->process_to_run);
+   DEBUG0("Here!");
    xbt_swag_remove(process, simix_global->process_list);
+   DEBUG2("%p here! killing %p",simix_global->current_process,process);
    xbt_context_kill(process->simdata->context);
 
+   DEBUG0("Here!");
    if(process==SIMIX_process_self()) {
       /* I just killed myself */
+     DEBUG0("Here!");
       xbt_context_yield();
    }
+   DEBUG0("Here!");
 }
 
 /**
@@ -224,7 +217,7 @@ void *SIMIX_process_get_data(smx_process_t process)
 void SIMIX_process_set_data(smx_process_t process,void *data)
 {
   xbt_assert0((process != NULL), "Invalid parameters");
-  xbt_assert0((process->data == NULL), "Data already set");
+  //xbt_assert0((process->data == NULL), "Data already set");
   
   process->data = data;