#include "mc_liveness.h"
#include "mc_private.h"
#include "mc_record.h"
+#include "mc_smx.h"
+#include "mc_client.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_liveness, mc,
"Logging specific to algorithms for liveness properties verification");
static xbt_dynar_t get_atomic_propositions_values()
{
- int res;
- int_f_void_t f;
unsigned int cursor = 0;
xbt_automaton_propositional_symbol_t ps = NULL;
xbt_dynar_t values = xbt_dynar_new(sizeof(int), NULL);
-
xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps) {
- f = (int_f_void_t) ps->function;
- res = f();
+ int res = xbt_automaton_propositional_symbol_evaluate(ps);
xbt_dynar_push_as(values, int, res);
}
return values;
}
-
-static mc_visited_pair_t is_reached_acceptance_pair(mc_pair_t pair){
-
- int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
-
- MC_SET_MC_HEAP;
+static mc_visited_pair_t is_reached_acceptance_pair(mc_pair_t pair) {
+ xbt_mheap_t heap = mmalloc_set_current_heap(mc_heap);
mc_visited_pair_t new_pair = NULL;
new_pair = MC_visited_pair_new(pair->num, pair->automaton_state, pair->atomic_propositions, pair->graph_state);
xbt_fifo_shift(mc_stack);
if (dot_output != NULL)
fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", initial_global_state->prev_pair, pair_test->num, initial_global_state->prev_req);
-
- if (!raw_mem_set)
- MC_SET_STD_HEAP;
-
+ mmalloc_set_current_heap(heap);
return NULL;
}
}
}
}
-
- if (!raw_mem_set)
- MC_SET_STD_HEAP;
-
+ mmalloc_set_current_heap(heap);
return new_pair;
-
}
-static void remove_acceptance_pair(int pair_num) {
-
- int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
-
- MC_SET_MC_HEAP;
+static void remove_acceptance_pair(int pair_num)
+{
+ xbt_mheap_t heap = mmalloc_set_current_heap(mc_heap);
unsigned int cursor = 0;
mc_visited_pair_t pair_test = NULL;
}
- if (!raw_mem_set)
- MC_SET_STD_HEAP;
+ mmalloc_set_current_heap(heap);
}
unsigned int cursor = 0;
xbt_automaton_propositional_symbol_t p = NULL;
xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, p) {
- if (strcmp(p->pred, l->u.predicat) == 0)
+ if (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;
}
}
-void MC_pre_modelcheck_liveness(void) {
+static void MC_modelcheck_liveness_main(void);
+static void MC_pre_modelcheck_liveness(void)
+{
initial_global_state->raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
mc_pair_t initial_pair = NULL;
smx_process_t process;
+ // TODO, fix this
+ MC_wait_for_requests();
MC_wait_for_requests();
MC_SET_MC_HEAP;
initial_pair->depth = 1;
/* Get enabled processes and insert them in the interleave set of the graph_state */
- xbt_swag_foreach(process, simix_global->process_list) {
+ MC_EACH_SIMIX_PROCESS(process,
if (MC_process_is_enabled(process)) {
MC_state_interleave_process(initial_pair->graph_state, process);
}
- }
+ );
initial_pair->requests = MC_state_interleave_size(initial_pair->graph_state);
initial_pair->search_cycle = 0;
MC_SET_STD_HEAP;
- MC_modelcheck_liveness();
+ MC_modelcheck_liveness_main();
if (initial_global_state->raw_mem_set)
MC_SET_MC_HEAP;
-
-
}
-void MC_modelcheck_liveness() {
-
+static void MC_modelcheck_liveness_main(void)
+{
smx_process_t process = NULL;
mc_pair_t current_pair = NULL;
int value, res, visited_num = -1;
/* Update current state in buchi automaton */
_mc_property_automaton->current_state = current_pair->automaton_state;
- XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d, interleave size %d, pair_num %d)",
+ XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d, interleave size = %d, pair_num = %d, requests = %d)",
current_pair->depth, current_pair->search_cycle,
- MC_state_interleave_size(current_pair->graph_state), current_pair->num);
+ MC_state_interleave_size(current_pair->graph_state), current_pair->num,
+ current_pair->requests);
if (current_pair->requests > 0) {
MC_SET_STD_HEAP;
}
- char* req_str = MC_request_to_string(req, value);
- XBT_DEBUG("Execute: %s", req_str);
+ char* req_str = MC_request_to_string(req, value, MC_REQUEST_SIMIX);
+ XBT_DEBUG("Execute: %s", req_str);
xbt_free(req_str);
/* Set request as executed */
mc_stats->visited_pairs++;
/* Answer the request */
- SIMIX_simcall_handle(req, value);
+ MC_simcall_handle(req, value);
/* Wait for requests (schedules processes) */
MC_wait_for_requests();
next_pair->atomic_propositions = get_atomic_propositions_values();
next_pair->depth = current_pair->depth + 1;
/* Get enabled processes and insert them in the interleave set of the next graph_state */
- xbt_swag_foreach(process, simix_global->process_list) {
+ MC_EACH_SIMIX_PROCESS(process,
if (MC_process_is_enabled(process)) {
MC_state_interleave_process(next_pair->graph_state, process);
}
- }
+ );
next_pair->requests = MC_state_interleave_size(next_pair->graph_state);
} /* End of while(xbt_fifo_size(mc_stack) > 0) */
}
+
+void MC_modelcheck_liveness(void)
+{
+ XBT_DEBUG("Starting the liveness algorithm");
+ xbt_assert(mc_mode == MC_MODE_SERVER);
+ _sg_mc_liveness = 1;
+
+ xbt_mheap_t heap = mmalloc_set_current_heap(mc_heap);
+
+ /* Create exploration stack */
+ mc_stack = xbt_fifo_new();
+
+ /* Create the initial state */
+ initial_global_state = xbt_new0(s_mc_global_t, 1);
+
+ MC_SET_STD_HEAP;
+
+ MC_pre_modelcheck_liveness();
+
+ /* We're done */
+ MC_print_statistics(mc_stats);
+ xbt_free(mc_time);
+
+ mmalloc_set_current_heap(heap);
+
+}