From: Arnaud Legrand Date: Wed, 25 Apr 2012 22:14:37 +0000 (+0200) Subject: Ensure that the same process never appears twice in the list of process_to_run. X-Git-Tag: v3_7~63^2~5 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/84363409250e5a325ad2efbb7c93c85b9ed332ea?hp=30b2d25dd879ac6a3d9a48ab48129f87a02f03f1 Ensure that the same process never appears twice in the list of process_to_run. 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. --- diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index 4ef99fc25d..d08aead971 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -289,8 +289,8 @@ void SIMIX_process_kill(smx_process_t process) { 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 { - 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); } } } diff --git a/src/simix/smx_smurf.c b/src/simix/smx_smurf.c index 4e7c79da76..df7fb256c9 100644 --- a/src/simix/smx_smurf.c +++ b/src/simix/smx_smurf.c @@ -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_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; } }