Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
poor damage control for tonight only
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 7 Mar 2019 23:13:08 +0000 (00:13 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 7 Mar 2019 23:13:08 +0000 (00:13 +0100)
src/msg/msg_process.cpp
src/s4u/s4u_Actor.cpp
src/simix/ActorImpl.cpp
teshsuite/msg/cloud-migration/cloud-migration.tesh

index 2b22f1e..e4acc92 100644 (file)
@@ -71,22 +71,25 @@ msg_process_t MSG_process_create_with_environment(const char *name, xbt_main_fun
   if (code)
     function = simgrid::xbt::wrap_main(code, argc, static_cast<const char* const*>(argv));
 
   if (code)
     function = simgrid::xbt::wrap_main(code, argc, static_cast<const char* const*>(argv));
 
-  simgrid::s4u::ActorPtr actor = simgrid::s4u::Actor::init(std::move(name), host);
-  actor->extension<simgrid::msg::ActorUserData>()->set_user_data(data);
-
-  xbt_dict_cursor_t cursor = nullptr;
-  char* key;
-  char* value;
-  xbt_dict_foreach (properties, cursor, key, value)
-    actor->set_property(key, value);
-  xbt_dict_free(&properties);
+  simgrid::s4u::ActorPtr actor;
 
   try {
 
   try {
-    actor->start(std::move(function));
+    if (data != nullptr) {
+      actor = simgrid::s4u::Actor::init(std::move(name), host);
+      actor->extension<simgrid::msg::ActorUserData>()->set_user_data(data);
+      xbt_dict_cursor_t cursor = nullptr;
+      char* key;
+      char* value;
+      xbt_dict_foreach (properties, cursor, key, value)
+        actor->set_property(key, value);
+      actor->start(std::move(function));
+    } else
+      actor = simgrid::s4u::Actor::create(std::move(name), host, std::move(function));
   } catch (simgrid::HostFailureException const&) {
     xbt_die("Could not launch a new process on failed host %s.", host->get_cname());
   }
 
   } catch (simgrid::HostFailureException const&) {
     xbt_die("Could not launch a new process on failed host %s.", host->get_cname());
   }
 
+  xbt_dict_free(&properties);
   for (int i = 0; i != argc; ++i)
     xbt_free(argv[i]);
   xbt_free(argv);
   for (int i = 0; i != argc; ++i)
     xbt_free(argv[i]);
   xbt_free(argv);
index f31600a..34ae162 100644 (file)
@@ -41,23 +41,25 @@ ActorPtr Actor::self()
 }
 ActorPtr Actor::init(std::string name, s4u::Host* host)
 {
 }
 ActorPtr Actor::init(std::string name, s4u::Host* host)
 {
-  return SIMIX_process_self()->init(std::move(name), host)->iface();
+  smx_actor_t self = SIMIX_process_self();
+  simgrid::kernel::actor::ActorImpl* actor =
+      simgrid::simix::simcall([self, name, host] { return self->init(std::move(name), host).get(); });
+  intrusive_ptr_release(actor);
+  return actor->ciface();
 }
 
 ActorPtr Actor::start(std::function<void()> code)
 {
 }
 
 ActorPtr Actor::start(std::function<void()> code)
 {
-  simgrid::simix::simcall([this, code] { return this->get_impl()->start(code); });
+  simgrid::simix::simcall([this, code] { pimpl_->start(code); });
   return this;
 }
 
 ActorPtr Actor::create(std::string name, s4u::Host* host, std::function<void()> code)
 {
   return this;
 }
 
 ActorPtr Actor::create(std::string name, s4u::Host* host, std::function<void()> code)
 {
-  smx_actor_t self = SIMIX_process_self();
-
   simgrid::kernel::actor::ActorImpl* actor =
   simgrid::kernel::actor::ActorImpl* actor =
-      simgrid::simix::simcall([self, name, host, code] { return self->init(std::move(name), host)->start(code); });
+      simcall_process_create(std::move(name), std::move(code), nullptr, host, nullptr);
 
 
-  return actor->ciface();
+  return actor->iface();
 }
 
 ActorPtr Actor::create(std::string name, s4u::Host* host, const std::string& function, std::vector<std::string> args)
 }
 
 ActorPtr Actor::create(std::string name, s4u::Host* host, const std::string& function, std::vector<std::string> args)
index 4e02287..2e604a9 100644 (file)
@@ -488,7 +488,11 @@ ActorImplPtr ActorImpl::create(std::string name, simix::ActorCode code, void* da
 {
   XBT_DEBUG("Start actor %s@'%s'", name.c_str(), host->get_cname());
 
 {
   XBT_DEBUG("Start actor %s@'%s'", name.c_str(), host->get_cname());
 
-  ActorImplPtr actor = SIMIX_process_self()->init(simgrid::xbt::string(name), host);
+  ActorImplPtr actor;
+  if (parent_actor != nullptr)
+    actor = parent_actor->init(simgrid::xbt::string(name), host);
+  else
+    actor = SIMIX_process_self()->init(simgrid::xbt::string(name), host);
 
   /* actor data */
   actor->set_user_data(data);
 
   /* actor data */
   actor->set_user_data(data);
index d4812c6..124b61a 100644 (file)
@@ -4,9 +4,9 @@ $ $SG_TEST_EXENV ${bindir:=.}/cloud-migration ${platfdir}/small_platform.xml --l
 > [132.765801] (1:master_@Fafard) Test: Migrate a VM with 100 Mbytes RAM
 > [146.111793] (1:master_@Fafard) VM0 migrated: Fafard->Tremblay in 13.346 s
 > [146.111793] (1:master_@Fafard) Test: Migrate two VMs at once from PM0 to PM1
 > [132.765801] (1:master_@Fafard) Test: Migrate a VM with 100 Mbytes RAM
 > [146.111793] (1:master_@Fafard) VM0 migrated: Fafard->Tremblay in 13.346 s
 > [146.111793] (1:master_@Fafard) Test: Migrate two VMs at once from PM0 to PM1
-> [411.566271] (7:mig_wrk@Fafard) VM1 migrated: Fafard->Tremblay in 265.454 s
+> [411.566271] (8:mig_wrk@Fafard) VM1 migrated: Fafard->Tremblay in 265.454 s
 > [411.566271] (6:mig_wrk@Fafard) VM0 migrated: Fafard->Tremblay in 265.454 s
 > [10146.111793] (1:master_@Fafard) Test: Migrate two VMs at once to different PMs
 > [411.566271] (6:mig_wrk@Fafard) VM0 migrated: Fafard->Tremblay in 265.454 s
 > [10146.111793] (1:master_@Fafard) Test: Migrate two VMs at once to different PMs
-> [10362.620589] (13:mig_wrk@Fafard) VM1 migrated: Fafard->Bourassa in 216.509 s
+> [10362.620589] (14:mig_wrk@Fafard) VM1 migrated: Fafard->Bourassa in 216.509 s
 > [10411.547334] (12:mig_wrk@Fafard) VM0 migrated: Fafard->Tremblay in 265.436 s
 > [20146.111793] (0:maestro@) Bye (simulation time 20146.1)
 > [10411.547334] (12:mig_wrk@Fafard) VM0 migrated: Fafard->Tremblay in 265.436 s
 > [20146.111793] (0:maestro@) Bye (simulation time 20146.1)