Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Ensure that the same process never appears twice in the list of process_to_run.
authorArnaud Legrand <arnaud.legrand@imag.fr>
Wed, 25 Apr 2012 22:14:37 +0000 (00:14 +0200)
committerArnaud Legrand <arnaud.legrand@imag.fr>
Wed, 25 Apr 2012 23:13:39 +0000 (01:13 +0200)
Otherwise, it would be awaken twice. The first time, it would execute then
wait on the completion of a new simcall. The second time it would appear
to return from the new simcall but the simcall would not have been
executed.

Since resume and kill are particular functions/simcalls that change
the behavior of other process, it is ok if the process was already in the
process_to_run list (although it must not appear twice). For other simcalls,
I think it is invalid if two simcalls lead the scheduling of the same
process.

src/simix/smx_process.c
src/simix/smx_smurf.c

index 4ef99fc..d08aead 100644 (file)
@@ -289,8 +289,8 @@ void SIMIX_process_kill(smx_process_t process) {
         break;
     }
   }
         break;
     }
   }
-
-  xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, process);
+  if(!xbt_dynar_member(simix_global->process_to_run, &(process)))
+    xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, process);
 }
 
 /**
 }
 
 /**
@@ -410,7 +410,8 @@ void SIMIX_process_resume(smx_process_t process, smx_process_t issuer)
       }
     }
     else {
       }
     }
     else {
-      xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, process);
+      if(!xbt_dynar_member(simix_global->process_to_run, &(process)))
+        xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, process);
     }
   }
 }
     }
   }
 }
index 4e7c79d..df7fb25 100644 (file)
@@ -33,7 +33,10 @@ void SIMIX_simcall_answer(smx_simcall_t simcall)
     XBT_DEBUG("Answer simcall %s (%d) issued by %s (%p)", SIMIX_simcall_name(simcall->call), (int)simcall->call,
         simcall->issuer->name, simcall->issuer);
     simcall->issuer->simcall.call = SIMCALL_NONE;
     XBT_DEBUG("Answer simcall %s (%d) issued by %s (%p)", SIMIX_simcall_name(simcall->call), (int)simcall->call,
         simcall->issuer->name, simcall->issuer);
     simcall->issuer->simcall.call = SIMCALL_NONE;
-    xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, simcall->issuer);
+    if(!xbt_dynar_member(simix_global->process_to_run, &(simcall->issuer)))
+      xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, simcall->issuer);
+    else
+      DIE_IMPOSSIBLE;
   }
 }
 
   }
 }