Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Define and use a function to run the processes to run.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 10 May 2011 06:14:56 +0000 (08:14 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 10 May 2011 06:33:52 +0000 (08:33 +0200)
src/mc/mc_global.c
src/simix/process_private.h
src/simix/smx_global.c
src/simix/smx_process.c

index 9fcb58c..1142da7 100644 (file)
@@ -81,12 +81,7 @@ void MC_wait_for_requests(void)
   unsigned int iter;
 
   while (xbt_dynar_length(simix_global->process_to_run)) {
-    SIMIX_context_runall(simix_global->process_to_run);
-
-    xbt_dynar_t tmp = simix_global->process_that_ran;
-    simix_global->process_that_ran = simix_global->process_to_run;
-    simix_global->process_to_run = tmp;
-    xbt_dynar_reset(simix_global->process_to_run);
+    SIMIX_process_runall();
     xbt_dynar_foreach(simix_global->process_that_ran, iter, process) {
       req = &process->request;
       if (req->call != REQ_NO_REQ && !MC_request_is_visible(req))
index 8df718c..93b294d 100644 (file)
@@ -53,6 +53,7 @@ void SIMIX_process_create(smx_process_t *process,
                           const char *hostname,
                           int argc, char **argv,
                           xbt_dict_t properties);
+void SIMIX_process_runall(void);
 void SIMIX_process_kill(smx_process_t process);
 void SIMIX_process_killall(smx_process_t issuer);
 smx_process_t SIMIX_process_create_from_wrapper(smx_process_arg_t args);
index 89fec34..b4de7e8 100644 (file)
@@ -200,11 +200,7 @@ void SIMIX_run(void)
     while (xbt_dynar_length(simix_global->process_to_run)) {
       XBT_DEBUG("New Sub-Schedule Round; size(queue)=%lu",
               xbt_dynar_length(simix_global->process_to_run));
-      SIMIX_context_runall(simix_global->process_to_run);
-      xbt_dynar_t tmp = simix_global->process_that_ran;
-      simix_global->process_that_ran = simix_global->process_to_run;
-      simix_global->process_to_run = tmp;
-      xbt_dynar_reset(simix_global->process_to_run);
+      SIMIX_process_runall();
       xbt_dynar_foreach(simix_global->process_that_ran, iter, process) {
         if (process->request.call != REQ_NO_REQ) {
           XBT_DEBUG("Handling request %p", &process->request);
index 3296198..2713127 100644 (file)
@@ -167,6 +167,24 @@ void SIMIX_process_create(smx_process_t *process,
 }
 
 /**
+ * \brief Executes the processes from simix_global->process_to_run.
+ *
+ * The processes of simix_global->process_to_run are run (in parallel if
+ * possible).  On exit, simix_global->process_to_run is empty, and
+ * simix_global->process_that_ran contains the list of processes that just ran.
+ * The two lists are swapped so, be careful when using them before and after a
+ * call to this function.
+ */
+void SIMIX_process_runall(void)
+{
+  SIMIX_context_runall(simix_global->process_to_run);
+  xbt_dynar_t tmp = simix_global->process_that_ran;
+  simix_global->process_that_ran = simix_global->process_to_run;
+  simix_global->process_to_run = tmp;
+  xbt_dynar_reset(simix_global->process_to_run);
+}
+
+/**
  * \brief Internal function to kill a SIMIX process.
  *
  * This function may be called when a REQ_PROCESS_KILL request occurs,