Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Actor::by_pid: also search through the dead actors
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 1 Aug 2019 20:44:06 +0000 (22:44 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 1 Aug 2019 20:44:09 +0000 (22:44 +0200)
Finally, my trick works with it. MPI ranks are not garbage collected
as soon as they end because the MPI instance keeps a reference on
them. With this, by_pid() works properly, even on dead but not
collected actors.

But this only works until the trash is emptied, obviously. This seem
to be enough for the test I wanted to get running, so I will not fix
that point tonight.

src/kernel/actor/ActorImpl.cpp

index c31407c..fc75399 100644 (file)
@@ -59,7 +59,8 @@ ActorImpl::ActorImpl(const simgrid::xbt::string& name, s4u::Host* host) : host_(
   simcall.issuer = this;
 }
 
-ActorImpl::~ActorImpl() {
+ActorImpl::~ActorImpl()
+{
   context_->iwannadie = false; // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops
   simgrid::simix::simcall([this] { simgrid::s4u::Actor::on_destruction(*ciface()); });
   context_->iwannadie = true;
@@ -624,8 +625,14 @@ const std::vector<smx_actor_t>& simgrid::simix::process_get_runnable()
 /** @brief Returns the process from PID. */
 smx_actor_t SIMIX_process_from_PID(aid_t PID)
 {
-  auto actor = simix_global->process_list.find(PID);
-  return actor == simix_global->process_list.end() ? nullptr : actor->second;
+  auto item = simix_global->process_list.find(PID);
+  if (item == simix_global->process_list.end()) {
+    for (auto& a : simix_global->actors_to_destroy)
+      if (a.get_pid() == PID)
+        return &a;
+    return nullptr; // Not found, even in the trash
+  }
+  return item->second;
 }
 
 void SIMIX_process_on_exit(smx_actor_t actor, int_f_pvoid_pvoid_t fun, void* data)