X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f9436b840852218b39dce22d6057b6f223168daa..3c038eac822ac8fbc74a278571574a13de0bd17f:/src/simix/ActorImpl.cpp diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 758d26d432..2c59aab6d3 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -10,20 +10,20 @@ #include -#include -#include -#include -#include -#include +#include "xbt/dict.h" +#include "xbt/ex.hpp" +#include "xbt/functional.hpp" +#include "xbt/log.h" +#include "xbt/sysdep.h" #include "simgrid/s4u/Host.hpp" -#include +#include "mc/mc.h" #include "smx_private.h" +#include "src/kernel/activity/SleepImpl.hpp" #include "src/kernel/activity/SynchroIo.hpp" #include "src/kernel/activity/SynchroRaw.hpp" -#include "src/kernel/activity/SynchroSleep.hpp" #include "src/mc/mc_replay.h" #include "src/mc/remote/Client.hpp" #include "src/msg/msg_private.h" @@ -81,26 +81,24 @@ int SIMIX_process_has_pending_comms(smx_actor_t process) { */ void SIMIX_process_cleanup(smx_actor_t process) { - XBT_DEBUG("Cleanup process %s (%p), waiting synchro %p", - process->name.c_str(), process, process->waiting_synchro); + XBT_DEBUG("Cleanup process %s (%p), waiting synchro %p", process->name.c_str(), process, process->waiting_synchro); process->finished = true; SIMIX_process_on_exit_runall(process); /* Unregister from the kill timer if any */ if (process->kill_timer != nullptr) - SIMIX_timer_remove(process->kill_timer); + SIMIX_timer_remove(process->kill_timer); xbt_os_mutex_acquire(simix_global->mutex); /* cancel non-blocking communications */ smx_activity_t synchro = static_cast(process->comms.front()); while (not process->comms.empty()) { - simgrid::kernel::activity::Comm *comm = static_cast(synchro); + simgrid::kernel::activity::CommImpl* comm = static_cast(synchro); /* make sure no one will finish the comm after this process is destroyed, * because src_proc or dst_proc would be an invalid pointer */ - comm->cancel(); if (comm->src_proc == process) { XBT_DEBUG("Found an unfinished send comm %p (detached = %d), state %d, src = %p, dst = %p", @@ -112,9 +110,7 @@ void SIMIX_process_cleanup(smx_actor_t process) XBT_DEBUG("Don't destroy it since it's a detached comm and I'm the sender"); else comm->unref(); - - } - else if (comm->dst_proc == process){ + } else if (comm->dst_proc == process) { XBT_DEBUG("Found an unfinished recv comm %p, state %d, src = %p, dst = %p", comm, (int)comm->state, comm->src_proc, comm->dst_proc); comm->dst_proc = nullptr; @@ -123,13 +119,12 @@ void SIMIX_process_cleanup(smx_actor_t process) /* the comm will be freed right now, remove it from the sender */ comm->src_proc->comms.remove(comm); } - - comm->unref(); } else { xbt_die("Communication synchro %p is in my list but I'm not the sender nor the receiver", synchro); } process->comms.pop_front(); synchro = static_cast(process->comms.front()); + comm->cancel(); } XBT_DEBUG("%p should not be run anymore",process); @@ -428,9 +423,12 @@ void SIMIX_process_kill(smx_actor_t process, smx_actor_t issuer) { /* destroy the blocking synchro if any */ if (process->waiting_synchro) { - simgrid::kernel::activity::Exec *exec = dynamic_cast(process->waiting_synchro); - simgrid::kernel::activity::Comm *comm = dynamic_cast(process->waiting_synchro); - simgrid::kernel::activity::Sleep *sleep = dynamic_cast(process->waiting_synchro); + simgrid::kernel::activity::ExecImpl* exec = + dynamic_cast(process->waiting_synchro); + simgrid::kernel::activity::CommImpl* comm = + dynamic_cast(process->waiting_synchro); + simgrid::kernel::activity::SleepImpl* sleep = + dynamic_cast(process->waiting_synchro); simgrid::kernel::activity::Raw *raw = dynamic_cast(process->waiting_synchro); simgrid::kernel::activity::Io *io = dynamic_cast(process->waiting_synchro); @@ -440,16 +438,11 @@ void SIMIX_process_kill(smx_actor_t process, smx_actor_t issuer) { } else if (comm != nullptr) { process->comms.remove(process->waiting_synchro); comm->cancel(); - // Remove first occurrence of &process->simcall: - auto i = boost::range::find( - process->waiting_synchro->simcalls, - &process->simcall); + auto i = boost::range::find(process->waiting_synchro->simcalls, &process->simcall); if (i != process->waiting_synchro->simcalls.end()) process->waiting_synchro->simcalls.remove(&process->simcall); - comm->unref(); - } else if (sleep != nullptr) { SIMIX_process_sleep_destroy(process->waiting_synchro); @@ -492,18 +485,21 @@ void SIMIX_process_throw(smx_actor_t process, xbt_errcat_t cat, int value, const /* cancel the blocking synchro if any */ if (process->waiting_synchro) { - simgrid::kernel::activity::Exec *exec = dynamic_cast(process->waiting_synchro); + simgrid::kernel::activity::ExecImpl* exec = + dynamic_cast(process->waiting_synchro); if (exec != nullptr) { SIMIX_execution_cancel(process->waiting_synchro); } - simgrid::kernel::activity::Comm *comm = dynamic_cast(process->waiting_synchro); + simgrid::kernel::activity::CommImpl* comm = + dynamic_cast(process->waiting_synchro); if (comm != nullptr) { process->comms.remove(comm); comm->cancel(); } - simgrid::kernel::activity::Sleep *sleep = dynamic_cast(process->waiting_synchro); + simgrid::kernel::activity::SleepImpl* sleep = + dynamic_cast(process->waiting_synchro); if (sleep != nullptr) { SIMIX_process_sleep_destroy(process->waiting_synchro); if (not xbt_dynar_member(simix_global->process_to_run, &(process)) && process != SIMIX_process_self()) { @@ -699,7 +695,7 @@ void simcall_HANDLER_process_join(smx_simcall_t simcall, smx_actor_t process, do } static int SIMIX_process_join_finish(smx_process_exit_status_t status, smx_activity_t synchro){ - simgrid::kernel::activity::Sleep *sleep = static_cast(synchro); + simgrid::kernel::activity::SleepImpl* sleep = static_cast(synchro); if (sleep->surf_sleep) { sleep->surf_sleep->cancel(); @@ -759,7 +755,7 @@ smx_activity_t SIMIX_process_sleep(smx_actor_t process, double duration) if (host->isOff()) THROWF(host_error, 0, "Host %s failed, you cannot sleep there.", host->cname()); - simgrid::kernel::activity::Sleep *synchro = new simgrid::kernel::activity::Sleep(); + simgrid::kernel::activity::SleepImpl* synchro = new simgrid::kernel::activity::SleepImpl(); synchro->host = host; synchro->surf_sleep = host->pimpl_cpu->sleep(duration); synchro->surf_sleep->setData(synchro); @@ -771,7 +767,7 @@ smx_activity_t SIMIX_process_sleep(smx_actor_t process, double duration) void SIMIX_process_sleep_destroy(smx_activity_t synchro) { XBT_DEBUG("Destroy synchro %p", synchro); - simgrid::kernel::activity::Sleep *sleep = static_cast(synchro); + simgrid::kernel::activity::SleepImpl* sleep = static_cast(synchro); if (sleep->surf_sleep) { sleep->surf_sleep->unref();