Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Remove split the MCed and MCer part of MC_deadlock_check()
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 15 Mar 2016 13:54:40 +0000 (14:54 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 15 Mar 2016 14:09:57 +0000 (15:09 +0100)
src/mc/Client.cpp
src/mc/ModelChecker.cpp
src/mc/ModelChecker.hpp
src/mc/mc_comm_determinism.cpp
src/mc/mc_global.cpp
src/mc/mc_private.h
src/mc/mc_safety.cpp

index 38ebb68..fbbbe92 100644 (file)
 
 #include "src/mc/mc_protocol.h"
 #include "src/mc/Client.hpp"
+#include "src/mc/mc_request.h"
 
 // We won't need those once the separation MCer/MCed is complete:
 #include "src/mc/mc_ignore.h"
-#include "src/mc/mc_private.h" // MC_deadlock_check()
 #include "src/mc/mc_smx.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_client, mc, "MC client logic");
@@ -93,10 +93,22 @@ void Client::handleMessages()
 
     case MC_MESSAGE_DEADLOCK_CHECK:
       {
-        int result = MC_deadlock_check();
+        // Check deadlock:
+        bool deadlock = false;
+        smx_process_t process;
+        if (xbt_swag_size(simix_global->process_list)) {
+          deadlock = true;
+          xbt_swag_foreach(process, simix_global->process_list)
+            if (simgrid::mc::process_is_enabled(process)) {
+              deadlock = false;
+              break;
+            }
+        }
+
+        // Send result:
         s_mc_int_message_t answer;
         answer.type = MC_MESSAGE_DEADLOCK_CHECK_REPLY;
-        answer.value = result;
+        answer.value = deadlock;
         if (channel_.send(answer))
           xbt_die("Could not send response");
       }
index 4489b84..ca77039 100644 (file)
@@ -437,5 +437,24 @@ void ModelChecker::simcall_handle(simgrid::mc::Process& process, unsigned long p
       return;
 }
 
+bool ModelChecker::checkDeadlock()
+{
+  int res;
+  if ((res = this->process().getChannel().send(MC_MESSAGE_DEADLOCK_CHECK)))
+    xbt_die("Could not check deadlock state");
+  s_mc_int_message_t message;
+  ssize_t s = mc_model_checker->process().getChannel().receive(message);
+  if (s == -1)
+    xbt_die("Could not receive message");
+  if (s != sizeof(message) || message.type != MC_MESSAGE_DEADLOCK_CHECK_REPLY)
+    xbt_die("%s received unexpected message %s (%i, size=%i) "
+      "expected MC_MESSAGE_DEADLOCK_CHECK_REPLY (%i, size=%i)",
+      MC_mode_name(mc_mode),
+      MC_message_type_name(message.type), (int) message.type, (int) s,
+      (int) MC_MESSAGE_DEADLOCK_CHECK_REPLY, (int) sizeof(message)
+      );
+  return message.value != 0;
+}
+
 }
 }
index 7babe6a..9bde129 100644 (file)
@@ -71,6 +71,9 @@ public:
     mc_model_checker->wait_client(mc_model_checker->process());
   }
   void exit(int status);
+
+  bool checkDeadlock();
+
 private:
   void setup_ignore();
   bool handle_message(char* buffer, ssize_t size);
index 4cca3ce..0ed9c57 100644 (file)
@@ -432,7 +432,7 @@ static int MC_modelcheck_comm_determinism_main(void)
       visited_state = nullptr;
 
       /* Check for deadlocks */
-      if (MC_deadlock_check()) {
+      if (mc_model_checker->checkDeadlock()) {
         MC_show_deadlock(nullptr);
         return SIMGRID_MC_EXIT_DEADLOCK;
       }
index f3d14ae..2c40f43 100644 (file)
@@ -133,41 +133,6 @@ void MC_exit(void)
   //xbt_abort();
 }
 
-#if HAVE_MC
-int MC_deadlock_check()
-{
-  if (mc_mode == MC_MODE_SERVER) {
-    int res;
-    if ((res = mc_model_checker->process().getChannel().send(MC_MESSAGE_DEADLOCK_CHECK)))
-      xbt_die("Could not check deadlock state");
-    s_mc_int_message_t message;
-    ssize_t s = mc_model_checker->process().getChannel().receive(message);
-    if (s == -1)
-      xbt_die("Could not receive message");
-    if (s != sizeof(message) || message.type != MC_MESSAGE_DEADLOCK_CHECK_REPLY)
-      xbt_die("%s received unexpected message %s (%i, size=%i) "
-        "expected MC_MESSAGE_DEADLOCK_CHECK_REPLY (%i, size=%i)",
-        MC_mode_name(mc_mode),
-        MC_message_type_name(message.type), (int) message.type, (int) s,
-        (int) MC_MESSAGE_DEADLOCK_CHECK_REPLY, (int) sizeof(message)
-        );
-    return message.value;
-  }
-
-  bool deadlock = false;
-  smx_process_t process;
-  if (xbt_swag_size(simix_global->process_list)) {
-    deadlock = true;
-    xbt_swag_foreach(process, simix_global->process_list)
-      if (simgrid::mc::process_is_enabled(process)) {
-        deadlock = false;
-        break;
-      }
-  }
-  return deadlock;
-}
-#endif
-
 /**
  * \brief Re-executes from the state at position start all the transitions indicated by
  *        a given model-checker stack.
index 5045c9f..869042c 100644 (file)
@@ -47,7 +47,6 @@ XBT_PRIVATE extern FILE *dot_output;
 
 XBT_PRIVATE extern int user_max_depth_reached;
 
-XBT_PRIVATE int MC_deadlock_check(void);
 XBT_PRIVATE void MC_replay(xbt_fifo_t stack);
 XBT_PRIVATE void MC_replay_liveness(xbt_fifo_t stack);
 XBT_PRIVATE void MC_show_deadlock(smx_simcall_t req);
index b9ffea3..62cb15c 100644 (file)
@@ -180,7 +180,7 @@ int modelcheck_safety(void)
       visited_state = nullptr;
 
       /* Check for deadlocks */
-      if (MC_deadlock_check()) {
+      if (mc_model_checker->checkDeadlock()) {
         MC_show_deadlock(nullptr);
         return SIMGRID_MC_EXIT_DEADLOCK;
       }