Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
msg_simix alpha. All functions implemented.
[simgrid.git] / src / msg_simix / msg_simix_global.c
index 1a46780..0296d16 100644 (file)
@@ -3,7 +3,7 @@
 #include "xbt/log.h"
 #include "xbt/ex.h" /* ex_backtrace_display */
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_kernel, msg,        "Logging specific to MSG (kernel)");    
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_kernel, msg, "Logging specific to MSG (kernel)");    
 
 MSG_Global_t msg_global = NULL;
 
@@ -137,27 +137,27 @@ MSG_error_t MSG_main(void)
 
                while ( (smx_action = xbt_fifo_pop(actions_failed)) ) {
 
-                       xbt_fifo_item_t _cursor;
 
                        DEBUG1("** %s failed **",smx_action->name);
-                       xbt_fifo_foreach(smx_action->cond_list,_cursor,cond,smx_cond_t) {
+                       while ( (cond = xbt_fifo_pop(smx_action->cond_list)) ) {
                                SIMIX_cond_broadcast(cond);
-                               /* remove conditional from action */
-                               xbt_fifo_remove(smx_action->cond_list,cond);
                        }
+                       /* action finished, destroy it */
+                       SIMIX_action_destroy(smx_action);
                }
 
                while ( (smx_action = xbt_fifo_pop(actions_done)) ) {
-                       xbt_fifo_item_t _cursor;
 
                        DEBUG1("** %s done **",smx_action->name);
-                       xbt_fifo_foreach(smx_action->cond_list,_cursor,cond,smx_cond_t) {
+                       while ( (cond = xbt_fifo_pop(smx_action->cond_list)) ) {
                                SIMIX_cond_broadcast(cond);
-                               /* remove conditional from action */
-                               xbt_fifo_remove(smx_action->cond_list,cond);
                        }
+                       /* action finished, destroy it */
+                       SIMIX_action_destroy(smx_action);
                }
        }
+       xbt_fifo_free(actions_failed);
+       xbt_fifo_free(actions_done);
   return MSG_OK;
 }
 
@@ -170,8 +170,20 @@ MSG_error_t MSG_main(void)
  */
 int MSG_process_killall(int reset_PIDs)
 {
-       xbt_die("not implemented yet");
-  return 0;
+  m_process_t p = NULL;
+  m_process_t self = MSG_process_self();
+
+  while((p=xbt_fifo_pop(msg_global->process_list))) {
+    if(p!=self) MSG_process_kill(p);
+  }    
+
+  if(reset_PIDs>0) {
+    msg_global->PID = reset_PIDs;  
+    msg_global->session++;
+ }
+
+  return msg_global->PID;
+
 }
 
 /** \ingroup msg_simulation