Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Remove Process.is_self()
[simgrid.git] / src / mc / mc_visited.cpp
index bd6cb0a..15dd471 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2014. The SimGrid Team.
+/* Copyright (c) 2011-2015. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -11,7 +11,7 @@
 #include "mc_safety.h"
 #include "mc_liveness.h"
 #include "mc_private.h"
-#include "mc_process.h"
+#include "mc/Process.hpp"
 #include "mc_smx.h"
 
 extern "C" {
@@ -37,9 +37,8 @@ static int is_exploration_stack_state(mc_visited_state_t state){
 void visited_state_free(mc_visited_state_t state)
 {
   if (state) {
-    if(!is_exploration_stack_state(state)){
-      MC_free_snapshot(state->system_state);
-    }
+    if(!is_exploration_stack_state(state))
+      delete state->system_state;
     xbt_free(state);
   }
 }
@@ -55,19 +54,15 @@ void visited_state_free_voidp(void *s)
  */
 static mc_visited_state_t visited_state_new()
 {
-  mc_process_t process = &(mc_model_checker->process());
+  simgrid::mc::Process* process = &(mc_model_checker->process());
   mc_visited_state_t new_state = xbt_new0(s_mc_visited_state_t, 1);
   new_state->heap_bytes_used = mmalloc_get_bytes_used_remote(
-    MC_process_get_heap(process)->heaplimit,
-    MC_process_get_malloc_info(process));
+    process->get_heap()->heaplimit,
+    process->get_malloc_info());
 
-  if (MC_process_is_self(&mc_model_checker->process())) {
-    new_state->nb_processes = xbt_swag_size(simix_global->process_list);
-  } else {
-    MC_process_smx_refresh(&mc_model_checker->process());
-    new_state->nb_processes = xbt_dynar_length(
-      mc_model_checker->process().smx_process_infos);
-  }
+  MC_process_smx_refresh(&mc_model_checker->process());
+  new_state->nb_processes = xbt_dynar_length(
+    mc_model_checker->process().smx_process_infos);
 
   new_state->system_state = MC_take_snapshot(mc_stats->expanded_states);
   new_state->num = mc_stats->expanded_states;
@@ -77,22 +72,20 @@ static mc_visited_state_t visited_state_new()
 
 mc_visited_pair_t MC_visited_pair_new(int pair_num, xbt_automaton_state_t automaton_state, xbt_dynar_t atomic_propositions, mc_state_t graph_state)
 {
-  mc_process_t process = &(mc_model_checker->process());
+  simgrid::mc::Process* process = &(mc_model_checker->process());
   mc_visited_pair_t pair = NULL;
   pair = xbt_new0(s_mc_visited_pair_t, 1);
   pair->graph_state = graph_state;
   if(pair->graph_state->system_state == NULL)
     pair->graph_state->system_state = MC_take_snapshot(pair_num);
   pair->heap_bytes_used = mmalloc_get_bytes_used_remote(
-    MC_process_get_heap(process)->heaplimit,
-    MC_process_get_malloc_info(process));
-  if (MC_process_is_self(&mc_model_checker->process())) {
-    pair->nb_processes = xbt_swag_size(simix_global->process_list);
-  } else {
-    MC_process_smx_refresh(&mc_model_checker->process());
-    pair->nb_processes = xbt_dynar_length(
-      mc_model_checker->process().smx_process_infos);
-  }
+    process->get_heap()->heaplimit,
+    process->get_malloc_info());
+
+  MC_process_smx_refresh(&mc_model_checker->process());
+  pair->nb_processes = xbt_dynar_length(
+    mc_model_checker->process().smx_process_infos);
+
   pair->automaton_state = automaton_state;
   pair->num = pair_num;
   pair->other_num = -1;
@@ -350,7 +343,7 @@ mc_visited_state_t is_visited_state(mc_state_t graph_state)
       unsigned int cursor2 = 0;
       unsigned int index2 = 0;
       xbt_dynar_foreach(visited_states, cursor2, state_test){
-        if (state_test->num < min2) {
+        if (!MC_important_snapshot(state_test->system_state) && state_test->num < min2) {
           index2 = cursor2;
           min2 = state_test->num;
         }
@@ -467,7 +460,8 @@ int is_visited_pair(mc_visited_pair_t visited_pair, mc_pair_t pair) {
       unsigned int cursor2 = 0;
       unsigned int index2 = 0;
       xbt_dynar_foreach(visited_pairs, cursor2, pair_test) {
-        if (pair_test->num < min2) {
+        if (!MC_important_snapshot(pair_test->graph_state->system_state)
+            && pair_test->num < min2) {
           index2 = cursor2;
           min2 = pair_test->num;
         }