From 84363409250e5a325ad2efbb7c93c85b9ed332ea Mon Sep 17 00:00:00 2001 From: Arnaud Legrand Date: Thu, 26 Apr 2012 00:14:37 +0200 Subject: [PATCH] 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. --- src/simix/smx_process.c | 7 ++++--- src/simix/smx_smurf.c | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) 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; } } -- 2.20.1