Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Improvements to the MSG port on top of SIMIX network. All MSG tests pass now.
[simgrid.git] / src / gras / Virtu / sg_process.c
index 975c627..bc39cf2 100644 (file)
@@ -170,14 +170,19 @@ xbt_dict_t gras_process_properties(void)
 
 const char *xbt_procname(void)
 {
-  const char *res = NULL;
   smx_process_t process = SIMIX_process_self();
-  if (process != NULL)
-    res = SIMIX_process_get_name(process);
-  if (res)
-    return res;
-  else
-    return "";
+  /*FIXME: maestro used not have a simix process, now it does so 
+    SIMIX_process_self will return something different to NULL. This breaks
+    the old xbt_log logic that assumed that NULL was equivalent to maestro,
+    thus when printing it searches for maestro host name (which doesn't exists)
+    and breaks the logging.
+    As a hack we check for maestro by looking to the assigned host, if it is
+    NULL then we are sure is maestro
+  */
+  if (process != NULL && SIMIX_host_self())
+    return SIMIX_process_get_name(process);
+
+  return "";
 }
 
 int gras_os_getpid(void)
@@ -187,7 +192,8 @@ int gras_os_getpid(void)
   
   if (process != NULL){
     data = (gras_procdata_t *)SIMIX_process_get_data(process);
-    return data->pid;
+    if(data != NULL)
+      return data->pid;
   }
   
   return 0;
@@ -237,37 +243,13 @@ void gras_function_register(const char *name, xbt_main_func_t code)
 
 void gras_main()
 {
-  smx_cond_t cond = NULL;
-  smx_action_t action;
-  xbt_fifo_t actions_done = xbt_fifo_new();
-  xbt_fifo_t actions_failed = xbt_fifo_new();
-
   /* Clean IO before the run */
   fflush(stdout);
   fflush(stderr);
   SIMIX_init();
 
-  while (SIMIX_solve(actions_done, actions_failed) != -1.0) {
-    while ((action = xbt_fifo_pop(actions_failed))) {
-      DEBUG1("** %s failed **", action->name);
-      while ((cond = xbt_fifo_pop(action->cond_list))) {
-        SIMIX_cond_broadcast(cond);
-      }
-      /* action finished, destroy it */
-      //        SIMIX_action_destroy(action);
-    }
-
-    while ((action = xbt_fifo_pop(actions_done))) {
-      DEBUG1("** %s done **", action->name);
-      while ((cond = xbt_fifo_pop(action->cond_list))) {
-        SIMIX_cond_broadcast(cond);
-      }
-      /* action finished, destroy it */
-      //SIMIX_action_destroy(action);
-    }
-  }
-  xbt_fifo_free(actions_failed);
-  xbt_fifo_free(actions_done);
+  while (SIMIX_solve(NULL, NULL) != -1.0);
+  
   return;
 }