X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5dc6f3c7fb898d0b145d63384f013410fd042a59..1d95145df4657e19b9a02db53de4c9f758a0c6f5:/src/mc/mc_liveness.cpp diff --git a/src/mc/mc_liveness.cpp b/src/mc/mc_liveness.cpp index 927692d5b9..73995faf6f 100644 --- a/src/mc/mc_liveness.cpp +++ b/src/mc/mc_liveness.cpp @@ -1,23 +1,30 @@ -/* 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 * under the terms of the license (GNU LGPL) which comes with this package. */ +#include + #include #include -#include #include - -#include "mc_request.h" -#include "mc_liveness.h" -#include "mc_private.h" -#include "mc_record.h" -#include "mc_smx.h" -#include "mc_client.h" -#include "mc_replay.h" -#include "mc_safety.h" +#include +#include +#include +#include +#include + +#include "src/mc/mc_request.h" +#include "src/mc/mc_liveness.h" +#include "src/mc/mc_private.h" +#include "src/mc/mc_record.h" +#include "src/mc/mc_smx.h" +#include "src/mc/mc_client.h" +#include "src/mc/mc_replay.h" +#include "src/mc/mc_safety.h" +#include "src/mc/mc_exit.h" extern "C" { @@ -153,7 +160,7 @@ static int MC_automaton_evaluate_label(xbt_automaton_exp_label_t l, unsigned int cursor = 0; xbt_automaton_propositional_symbol_t p = NULL; xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, p) { - if (strcmp(xbt_automaton_propositional_symbol_get_name(p), l->u.predicat) == 0) + if (std::strcmp(xbt_automaton_propositional_symbol_get_name(p), l->u.predicat) == 0) return (int) xbt_dynar_get_as(atomic_propositions_values, cursor, int); } return -1; @@ -166,20 +173,20 @@ static int MC_automaton_evaluate_label(xbt_automaton_exp_label_t l, } } -static void MC_modelcheck_liveness_main(void); +static int MC_modelcheck_liveness_main(void); static void MC_pre_modelcheck_liveness(void) { mc_pair_t initial_pair = NULL; smx_process_t process; - MC_wait_for_requests(); + mc_model_checker->wait_for_requests(); acceptance_pairs = xbt_dynar_new(sizeof(mc_visited_pair_t), NULL); if(_sg_mc_visited > 0) visited_pairs = xbt_dynar_new(sizeof(mc_visited_pair_t), NULL); - initial_global_state->snapshot = MC_take_snapshot(0); + initial_global_state->snapshot = simgrid::mc::take_snapshot(0); initial_global_state->prev_pair = 0; unsigned int cursor = 0; @@ -207,11 +214,9 @@ static void MC_pre_modelcheck_liveness(void) xbt_fifo_unshift(mc_stack, initial_pair); } } - - MC_modelcheck_liveness_main(); } -static void MC_modelcheck_liveness_main(void) +static int MC_modelcheck_liveness_main(void) { smx_process_t process = NULL; mc_pair_t current_pair = NULL; @@ -251,7 +256,7 @@ static void MC_modelcheck_liveness_main(void) MC_dump_stack_liveness(mc_stack); MC_print_statistics(mc_stats); XBT_INFO("Counter-example depth : %d", counter_example_depth); - xbt_abort(); + return SIMGRID_MC_EXIT_LIVENESS; } } @@ -299,7 +304,7 @@ static void MC_modelcheck_liveness_main(void) MC_simcall_handle(req, value); /* Wait for requests (schedules processes) */ - MC_wait_for_requests(); + mc_model_checker->wait_for_requests(); current_pair->requests--; current_pair->exploration_started = 1; @@ -370,16 +375,19 @@ static void MC_modelcheck_liveness_main(void) } /* End of if (current_pair->requests > 0) else ... */ } /* End of while(xbt_fifo_size(mc_stack) > 0) */ - + + XBT_INFO("No property violation found."); + MC_print_statistics(mc_stats); + return SIMGRID_MC_EXIT_SUCCESS; } -void MC_modelcheck_liveness(void) +int MC_modelcheck_liveness(void) { if (mc_reduce_kind == e_mc_reduce_unset) mc_reduce_kind = e_mc_reduce_none; XBT_INFO("Check the liveness property %s", _sg_mc_property_file); MC_automaton_load(_sg_mc_property_file); - MC_wait_for_requests(); + mc_model_checker->wait_for_requests(); XBT_DEBUG("Starting the liveness algorithm"); _sg_mc_liveness = 1; @@ -391,11 +399,12 @@ void MC_modelcheck_liveness(void) initial_global_state = xbt_new0(s_mc_global_t, 1); MC_pre_modelcheck_liveness(); + int res = MC_modelcheck_liveness_main(); /* We're done */ - XBT_INFO("No property violation found."); - MC_print_statistics(mc_stats); xbt_free(mc_time); + + return res; } }