Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Try to DRY in MC main loops
[simgrid.git] / src / mc / mc_safety.c
index a77883f..2a1df9b 100644 (file)
@@ -93,7 +93,7 @@ void MC_modelcheck_safety(void)
   xbt_fifo_item_t item = NULL;
   mc_state_t state_test = NULL;
   int pos;
   xbt_fifo_item_t item = NULL;
   mc_state_t state_test = NULL;
   int pos;
-  int visited_state = -1;
+  mc_visited_state_t visited_state = NULL;
   int enabled = 0;
 
   while (xbt_fifo_size(mc_stack) > 0) {
   int enabled = 0;
 
   while (xbt_fifo_size(mc_stack) > 0) {
@@ -115,19 +115,15 @@ void MC_modelcheck_safety(void)
     /* If there are processes to interleave and the maximum depth has not been reached
        then perform one step of the exploration algorithm */
     if (xbt_fifo_size(mc_stack) <= _sg_mc_max_depth && !user_max_depth_reached
     /* If there are processes to interleave and the maximum depth has not been reached
        then perform one step of the exploration algorithm */
     if (xbt_fifo_size(mc_stack) <= _sg_mc_max_depth && !user_max_depth_reached
-        && (req = MC_state_get_request(state, &value)) && visited_state == -1) {
+        && (req = MC_state_get_request(state, &value)) && visited_state == NULL) {
 
 
-      /* Debug information */
-      if (XBT_LOG_ISENABLED(mc_safety, xbt_log_priority_debug)) {
-        req_str = MC_request_to_string(req, value);
-        XBT_DEBUG("Execute: %s", req_str);
-        xbt_free(req_str);
-      }
+      MC_LOG_REQUEST(mc_safety, req, value);
 
 
-      MC_SET_MC_HEAP;
-      if (dot_output != NULL)
+      if (dot_output != NULL) {
+        MC_SET_MC_HEAP;
         req_str = MC_request_get_dot_output(req, value);
         req_str = MC_request_get_dot_output(req, value);
-      MC_SET_STD_HEAP;
+        MC_SET_STD_HEAP;
+      }
 
       MC_state_set_executed_request(state, req, value);
       mc_stats->executed_transitions++;
 
       MC_state_set_executed_request(state, req, value);
       mc_stats->executed_transitions++;
@@ -141,7 +137,7 @@ void MC_modelcheck_safety(void)
       }
 
       /* Answer the request */
       }
 
       /* Answer the request */
-      SIMIX_simcall_pre(req, value);
+      SIMIX_simcall_enter(req, value);
 
       /* Wait for requests (schedules processes) */
       MC_wait_for_requests();
 
       /* Wait for requests (schedules processes) */
       MC_wait_for_requests();
@@ -151,7 +147,7 @@ void MC_modelcheck_safety(void)
 
       next_state = MC_state_new();
 
 
       next_state = MC_state_new();
 
-      if ((visited_state = is_visited_state()) == -1) {
+      if ((visited_state = is_visited_state()) == NULL) {
 
         /* Get an enabled process and insert it in the interleave set of the next state */
         xbt_swag_foreach(process, simix_global->process_list) {
 
         /* Get an enabled process and insert it in the interleave set of the next state */
         xbt_swag_foreach(process, simix_global->process_list) {
@@ -175,7 +171,7 @@ void MC_modelcheck_safety(void)
 
         if (dot_output != NULL)
           fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", state->num,
 
         if (dot_output != NULL)
           fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", state->num,
-                  visited_state, req_str);
+                  visited_state->other_num == -1 ? visited_state->num : visited_state->other_num, req_str);
 
       }
 
 
       }
 
@@ -206,14 +202,14 @@ void MC_modelcheck_safety(void)
     } else {
 
       if ((xbt_fifo_size(mc_stack) > _sg_mc_max_depth) || user_max_depth_reached
     } else {
 
       if ((xbt_fifo_size(mc_stack) > _sg_mc_max_depth) || user_max_depth_reached
-          || visited_state != -1) {
+          || visited_state != NULL) {
 
 
-        if (user_max_depth_reached && visited_state == -1)
+        if (user_max_depth_reached && visited_state == NULL)
           XBT_DEBUG("User max depth reached !");
           XBT_DEBUG("User max depth reached !");
-        else if (visited_state == -1)
+        else if (visited_state == NULL)
           XBT_WARN("/!\\ Max depth reached ! /!\\ ");
         else
           XBT_WARN("/!\\ Max depth reached ! /!\\ ");
         else
-          XBT_DEBUG("State already visited, exploration stopped on this path.");
+          XBT_DEBUG("State already visited (equal to state %d), exploration stopped on this path.", visited_state->other_num == -1 ? visited_state->num : visited_state->other_num);
 
         if (mc_reduce_kind == e_mc_reduce_dpor) {
           /* Interleave enabled processes in the state in which they have been enabled for the first time */
 
         if (mc_reduce_kind == e_mc_reduce_dpor) {
           /* Interleave enabled processes in the state in which they have been enabled for the first time */
@@ -257,7 +253,7 @@ void MC_modelcheck_safety(void)
 
       MC_SET_STD_HEAP;
 
 
       MC_SET_STD_HEAP;
 
-      visited_state = -1;
+      visited_state = NULL;
 
       /* Check for deadlocks */
       if (MC_deadlock_check()) {
 
       /* Check for deadlocks */
       if (MC_deadlock_check()) {