Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
S4U version of actor-yield example
authorTakishipp <toufik.boubehziz@gmail.com>
Thu, 23 Nov 2017 09:19:10 +0000 (10:19 +0100)
committerTakishipp <toufik.boubehziz@gmail.com>
Thu, 23 Nov 2017 09:19:10 +0000 (10:19 +0100)
examples/s4u/README.doc
examples/s4u/actor-yield/s4u-actor-yield.cpp
src/s4u/s4u_actor.cpp

index 97be9a1..9de0797 100644 (file)
@@ -83,6 +83,12 @@ documentation, but it should remain readable directly.
     @ref examples/s4u/actor-migration/s4u-actor-migration.cpp \n
     Actors can move or be moved from a host to another with the @ref migrate method.
 
     @ref examples/s4u/actor-migration/s4u-actor-migration.cpp \n
     Actors can move or be moved from a host to another with the @ref migrate method.
 
+  - <b>Yielding to other actor</b>.
+    @ref examples/s4u/actor-yield/s4u-actor-yield.c\n
+    The @ref yield function interrupts the execution of the
+    current actor, leaving a chance to run to the other actor
+    that are ready to run at the exact same timestamp
+
 @section s4u_ex_synchro Inter-Actor Synchronization 
 
  - <b>Mutex: </b> @ref examples/s4u/mutex/s4u-mutex.cpp \n
 @section s4u_ex_synchro Inter-Actor Synchronization 
 
  - <b>Mutex: </b> @ref examples/s4u/mutex/s4u-mutex.cpp \n
index 6e79dc6..f554233 100644 (file)
@@ -8,11 +8,11 @@
 #include "src/simix/smx_private.h"
 #include <string>
 
 #include "src/simix/smx_private.h"
 #include <string>
 
-/* This example does not much: It just spans over-polite processes that yield a large amount
+/* This example does not much: It just spans over-polite actor that yield a large amount
 * of time before ending.
 *
 * of time before ending.
 *
-* This serves as an example for the s4u-actor-yield() function, with which a process can request
-* to be rescheduled after the other processes that are ready at the current timestamp.
+* This serves as an example for the s4u-actor-yield() function, with which an actor can request
+* to be rescheduled after the other actor that are ready at the current timestamp.
 *
 * It can also be used to benchmark our context-switching mechanism.
 */
 *
 * It can also be used to benchmark our context-switching mechanism.
 */
@@ -28,9 +28,8 @@ public:
 }
 void operator()()
 {
 }
 void operator()()
 {
- simgrid::s4u::ActorPtr actor;
  for (int i = 0; i < number_of_yields; i++)
  for (int i = 0; i < number_of_yields; i++)
actor->yield();
simgrid::s4u::this_actor::yield();
  XBT_INFO("I yielded %ld times. Goodbye now!", number_of_yields);
 }
 };
  XBT_INFO("I yielded %ld times. Goodbye now!", number_of_yields);
 }
 };
@@ -40,7 +39,7 @@ int main(int argc, char* argv[])
  simgrid::s4u::Engine e(&argc, argv);
  
  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
  simgrid::s4u::Engine e(&argc, argv);
  
  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
- "\tExample: %s msg_platform.xml msg_deployment.xml\n",
+ "\tExample: %s platform.xml deployment.xml\n",
  argv[0], argv[0]);
  
  e.loadPlatform(argv[1]);  /* - Load the platform description */
  argv[0], argv[0]);
  
  e.loadPlatform(argv[1]);  /* - Load the platform description */
index db27edc..0789eec 100644 (file)
@@ -120,11 +120,6 @@ int Actor::isSuspended()
   return simgrid::simix::kernelImmediate([this] { return pimpl_->suspended; });
 }
 
   return simgrid::simix::kernelImmediate([this] { return pimpl_->suspended; });
 }
 
-void Actor::yield()
-{
-  simgrid::simix::kernelImmediate([] { /* do nothing*/ });
-}
-
 void Actor::setKillTime(double time) {
   simcall_process_set_kill_time(pimpl_,time);
 }
 void Actor::setKillTime(double time) {
   simcall_process_set_kill_time(pimpl_,time);
 }
@@ -219,6 +214,11 @@ void sleep_for(double duration)
     simcall_process_sleep(duration);
 }
 
     simcall_process_sleep(duration);
 }
 
+void yield()
+{
+  simgrid::simix::kernelImmediate([] { /* do nothing*/ });
+}
+
 XBT_PUBLIC(void) sleep_until(double timeout)
 {
   double now = SIMIX_get_clock();
 XBT_PUBLIC(void) sleep_until(double timeout)
 {
   double now = SIMIX_get_clock();