Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Read host name from remote process
[simgrid.git] / src / mc / mc_global.c
index 85dacbc..56ad792 100644 (file)
@@ -35,6 +35,7 @@
 #include "mc_liveness.h"
 #include "mc_private.h"
 #include "mc_unw.h"
+#include "mc_smx.h"
 #endif
 #include "mc_record.h"
 #include "mc_protocol.h"
@@ -178,6 +179,9 @@ void MC_init_pid(pid_t pid, int socket)
     MC_ignore_global_variable("smx_total_comms");
 
     if (mc_mode == MC_MODE_STANDALONE || mc_mode == MC_MODE_CLIENT) {
+      /* Those requests are handled on the client side and propagated by message
+       * to the server: */
+
       MC_ignore_heap(mc_time, simix_process_maxpid * sizeof(double));
 
       smx_process_t process;
@@ -311,16 +315,34 @@ void MC_exit(void)
 
 int MC_deadlock_check()
 {
+  if (mc_mode == MC_MODE_SERVER) {
+    int res;
+    if ((res = MC_protocol_send_simple_message(mc_model_checker->process.socket,
+      MC_MESSAGE_DEADLOCK_CHECK)))
+      xbt_die("Could not check deadlock state");
+    s_mc_int_message_t message;
+    ssize_t s = MC_receive_message(mc_model_checker->process.socket, &message, sizeof(message));
+    if (s == -1)
+      xbt_die("Could not receive message");
+    else if (s != sizeof(message) || message.type != MC_MESSAGE_DEADLOCK_CHECK_REPLY) {
+      xbt_die("Unexpected message, expected MC_MESSAGE_DEADLOCK_CHECK_REPLY %i %i vs %i %i",
+        (int) s, (int) message.type, (int) sizeof(message), (int) MC_MESSAGE_DEADLOCK_CHECK_REPLY
+        );
+    }
+    else
+      return message.value;
+  }
+
   int 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 (MC_request_is_enabled(&process->simcall)) {
+    MC_EACH_SIMIX_PROCESS(process,
+      if (MC_process_is_enabled(process)) {
         deadlock = FALSE;
         break;
       }
-    }
+    );
   }
   return deadlock;
 }
@@ -453,7 +475,9 @@ void MC_replay(xbt_fifo_t stack)
     if (saved_req) {
       /* because we got a copy of the executed request, we have to fetch the  
          real one, pointed by the request field of the issuer process */
-      req = &saved_req->issuer->simcall;
+
+      const smx_process_t issuer = MC_smx_simcall_get_issuer(saved_req);
+      req = &issuer->simcall;
 
       /* Debug information */
       if (XBT_LOG_ISENABLED(mc_global, xbt_log_priority_debug)) {
@@ -467,7 +491,7 @@ void MC_replay(xbt_fifo_t stack)
       if (_sg_mc_comms_determinism || _sg_mc_send_determinism)
         call = mc_get_call_type(req);
 
-      SIMIX_simcall_handle(req, value);
+      MC_simcall_handle(req, value);
 
       MC_SET_MC_HEAP;
       if (_sg_mc_comms_determinism || _sg_mc_send_determinism)
@@ -538,7 +562,8 @@ void MC_replay_liveness(xbt_fifo_t stack)
         if (saved_req != NULL) {
           /* because we got a copy of the executed request, we have to fetch the
              real one, pointed by the request field of the issuer process */
-          req = &saved_req->issuer->simcall;
+          const smx_process_t issuer = MC_smx_simcall_get_issuer(saved_req);
+          req = &issuer->simcall;
 
           /* Debug information */
           if (XBT_LOG_ISENABLED(mc_global, xbt_log_priority_debug)) {
@@ -549,7 +574,7 @@ void MC_replay_liveness(xbt_fifo_t stack)
 
         }
 
-        SIMIX_simcall_handle(req, value);
+        MC_simcall_handle(req, value);
         MC_wait_for_requests();
       }