Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a bug notified on July 28, 2014 is finally solved \o/
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 12 Feb 2019 14:19:04 +0000 (15:19 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 12 Feb 2019 14:19:04 +0000 (15:19 +0100)
a true c++ exception is now raised if an actor is killed because its
host was turned off. It can be catched in the Java binding and set the
right MSG error status to MSG_HOST_FAILURE.
MSG_process_sleep can thus be marked as legacy and replaced by
s4u_actor_sleep_for

include/simgrid/actor.h
include/simgrid/msg.h
src/bindings/java/jmsg_process.cpp
src/msg/msg_gos.cpp
src/msg/msg_legacy.cpp
src/s4u/s4u_Actor.cpp

index 5aa30d1..01e8e07 100644 (file)
@@ -39,6 +39,7 @@ XBT_PUBLIC void sg_actor_kill(sg_actor_t actor);
 XBT_PUBLIC void sg_actor_kill_all();
 XBT_PUBLIC void sg_actor_set_kill_time(sg_actor_t actor, double kill_time);
 XBT_PUBLIC void sg_actor_yield();
+XBT_PUBLIC void sg_actor_sleep_for(double duration);
 SG_END_DECL()
 
 #endif /* INCLUDE_SIMGRID_ACTOR_H_ */
index b66155e..4cedf6e 100644 (file)
@@ -209,6 +209,8 @@ XBT_PUBLIC void MSG_process_killall();
 XBT_PUBLIC void MSG_process_set_kill_time(msg_process_t process, double kill_time);
 /** @brief Yield the current actor; let the other actors execute first */
 XBT_PUBLIC void MSG_process_yield();
+/*** @brief Sleep for the specified number of seconds */
+XBT_PUBLIC void MSG_process_sleep(double nb_sec);
 
 /** @brief Object representing an ongoing communication between processes.
  *
@@ -361,8 +363,6 @@ XBT_PUBLIC msg_error_t MSG_parallel_task_execute_with_timeout(msg_task_t task, d
 XBT_PUBLIC void MSG_task_set_priority(msg_task_t task, double priority);
 XBT_PUBLIC void MSG_task_set_bound(msg_task_t task, double bound);
 
-XBT_PUBLIC msg_error_t MSG_process_sleep(double nb_sec);
-
 XBT_PUBLIC void MSG_task_set_flops_amount(msg_task_t task, double flops_amount);
 XBT_PUBLIC double MSG_task_get_flops_amount(msg_task_t task);
 XBT_PUBLIC double MSG_task_get_remaining_work_ratio(msg_task_t task);
index fc495a5..2a90a8d 100644 (file)
@@ -224,14 +224,13 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended(JNIEnv * env
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep(JNIEnv *env, jclass cls, jlong jmillis, jint jnanos)
  {
   double time =  ((double)jmillis) / 1000 + ((double)jnanos) / 1000000000;
-  msg_error_t rv;
-  if (not simgrid::kernel::context::StopRequest::try_n_catch([&rv, &time]() { rv = MSG_process_sleep(time); })) {
+  msg_error_t rv = MSG_OK;
+  if (not simgrid::kernel::context::StopRequest::try_n_catch(
+          [&time]() { simgrid::s4u::this_actor::sleep_for(time); })) {
     rv = MSG_HOST_FAILURE;
   }
   if (rv != MSG_OK) {
-    XBT_DEBUG("Something during the MSG_process_sleep invocation was wrong, trigger a HostFailureException");
-
-    jxbt_throw_host_failure(env, "");
+    jmsg_throw_status(env, rv);
   }
 }
 
index 803e509..e5f3194 100644 (file)
@@ -107,38 +107,6 @@ msg_error_t MSG_parallel_task_execute_with_timeout(msg_task_t task, double timeo
   return status;
 }
 
-/**
- * @brief Sleep for the specified number of seconds
- *
- * Makes the current process sleep until @a time seconds have elapsed.
- *
- * @param nb_sec a number of second
- */
-msg_error_t MSG_process_sleep(double nb_sec)
-{
-  msg_error_t status = MSG_OK;
-
-  try {
-    simgrid::s4u::this_actor::sleep_for(nb_sec);
-  } catch (simgrid::HostFailureException& e) {
-    status = MSG_HOST_FAILURE;
-  } catch (xbt_ex& e) {
-    if (e.category == cancel_error) {
-      XBT_DEBUG("According to the JAVA API, a sleep call should only deal with HostFailureException, I'm lost.");
-      // adsein: MSG_TASK_CANCELED is assigned when someone kills the process that made the sleep, this is not
-      // correct. For instance, when the node is turned off, the error should be MSG_HOST_FAILURE, which is by the way
-      // and according to the JAVA document, the only exception that can be triggered by MSG_Process_sleep call.
-      // To avoid possible impacts in the code, I just raised a host_failure exception for the moment in the JAVA code
-      // and did not change anythings at the C level.
-      // See comment in the jmsg_process.c file, function JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep(JNIEnv *env, jclass cls, jlong jmillis, jint jnanos)
-      status = MSG_TASK_CANCELED;
-    } else
-      throw;
-  }
-
-  return status;
-}
-
 /**
  * @brief Receives a task from a mailbox.
  *
index 431070e..38bc2ae 100644 (file)
@@ -123,7 +123,10 @@ void MSG_process_yield()
 {
   sg_actor_yield();
 }
-
+void MSG_process_sleep(double duration)
+{
+  sg_actor_sleep_for(duration);
+}
 /* ************************** NetZones *************************** */
 sg_netzone_t MSG_zone_get_root()
 {
index 3713c6d..15af517 100644 (file)
@@ -642,3 +642,8 @@ void sg_actor_yield()
 {
   simgrid::s4u::this_actor::yield();
 }
+
+void sg_actor_sleep_for(double duration)
+{
+  simgrid::s4u::this_actor::sleep_for(duration);
+}