Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add suspend/resume to S4U
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 21 Mar 2017 08:40:41 +0000 (09:40 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 21 Mar 2017 08:40:41 +0000 (09:40 +0100)
update the actor-migration example to perfectly match the
process-migration example in C/MSG

examples/s4u/actor-migration/s4u_actor-migration.cpp
examples/s4u/actor-migration/s4u_actor-migration.tesh
include/simgrid/s4u/Actor.hpp
src/s4u/s4u_actor.cpp

index c5ecf5f..5db96c6 100644 (file)
@@ -34,8 +34,8 @@ static void emigrant()
   identification->notify_all();
   checkpoint->unlock();
 
-  // TODO simgrid::s4u::this_actor::suspend(); to replace the sleep below
-  simgrid::s4u::this_actor::sleep_for(4);
+  simgrid::s4u::this_actor::suspend();
+
   XBT_INFO("I've been moved on this new host: %s", simgrid::s4u::this_actor::host()->cname());
   XBT_INFO("Uh, nothing to do here. Stopping now");
 }
@@ -51,7 +51,7 @@ static void policeman()
 
   controlled_process->migrate(simgrid::s4u::Host::by_name("Jacquelin")); /* - Move an emigrant to Jacquelin */
   XBT_INFO("I moved the emigrant");
-  // TODO simgrid::s4u::this_actor::resume()
+  controlled_process->resume();
 
   checkpoint->unlock();
 }
index ef6fad7..19b9f97 100644 (file)
@@ -8,7 +8,7 @@ $ $SG_TEST_EXENV ${bindir:=.}/s4u_actor-migration ${srcdir:=.}/small_platform.xm
 > [  0.000000] (emigrant@Boivin) Yeah, found something to do
 > [  0.000000] (policeman@Boivin) Wait at the checkpoint.
 > [  3.000000] (emigrant@Boivin) Moving back home after work
+> [  7.000000] (maestro@) Simulation time 7
+> [  7.000000] (emigrant@Jacquelin) I've been moved on this new host: Jacquelin
+> [  7.000000] (emigrant@Jacquelin) Uh, nothing to do here. Stopping now
 > [  7.000000] (policeman@Boivin) I moved the emigrant
-> [ 11.000000] (emigrant@Jacquelin) I've been moved on this new host: Jacquelin
-> [ 11.000000] (emigrant@Jacquelin) Uh, nothing to do here. Stopping now
-> [ 11.000000] (maestro@) Simulation time 11
index 016799a..9e34530 100644 (file)
@@ -212,6 +212,12 @@ public:
   /** Retrieves the PPID of that actor */
   int ppid();
 
+  /** Suspend an actor by suspending the task on which it was waiting for the completion. */
+  void suspend();
+
+  /** Resume a suspended process by resuming the task on which it was waiting for the completion. */
+  void resume();
+
   /** If set to true, the actor will automatically restart when its host reboots */
   void setAutoRestart(bool autorestart);
   /** Sets the time at which that actor should be killed */
@@ -302,6 +308,13 @@ namespace this_actor {
   /** @brief Returns the name of the host on which the process is running. */
   XBT_PUBLIC(Host*) host();
 
+  /** @brief Suspend the actor. */
+  XBT_PUBLIC(void) suspend();
+
+  /** @brief Resume the actor. */
+  XBT_PUBLIC(void) resume();
+
+  /** @brief Migrate the actor to a new host. */
   XBT_PUBLIC(void) migrate(Host* new_host);
 };
 
index 97d7ec1..16479c0 100644 (file)
@@ -82,6 +82,16 @@ int Actor::ppid()
   return this->pimpl_->ppid;
 }
 
+void Actor::suspend()
+{
+  simcall_process_suspend(pimpl_);
+}
+
+void Actor::resume()
+{
+  simcall_process_resume(pimpl_);
+}
+
 void Actor::setKillTime(double time) {
   simcall_process_set_kill_time(pimpl_,time);
 }
@@ -184,6 +194,16 @@ Host* host()
   return SIMIX_process_self()->host;
 }
 
+void suspend()
+{
+  simcall_process_suspend(SIMIX_process_self());
+}
+
+void resume()
+{
+  simcall_process_resume(SIMIX_process_self());
+}
+
 void migrate(Host* new_host)
 {
   simcall_process_set_host(SIMIX_process_self(), new_host);