1 /* Copyright (c) 2008-2012 Da SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "mc_private.h"
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_liveness, mc,
11 "Logging specific to algorithms for liveness properties verification");
13 xbt_dynar_t reached_pairs;
14 xbt_dynar_t reached_pairs_hash;
15 xbt_dynar_t visited_pairs;
16 xbt_dynar_t visited_pairs_hash;
17 xbt_dynar_t successors;
19 xbt_dynar_t hosts_table;
22 /* fast implementation of djb2 algorithm */
23 unsigned int hash_region(char *str, int str_len){
26 register unsigned int hash = 5381;
30 hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
37 int create_dump(int pair)
39 // Try to enable core dumps
40 struct rlimit core_limit;
41 core_limit.rlim_cur = RLIM_INFINITY;
42 core_limit.rlim_max = RLIM_INFINITY;
44 if(setrlimit(RLIMIT_CORE, &core_limit) < 0)
45 fprintf(stderr, "setrlimit: %s\nWarning: core dumps may be truncated or non-existant\n", strerror(errno));
50 // We are the child process -- run the actual program
55 // An error occurred, shouldn't happen
60 // We are the parent process -- wait for the child process to exit
63 printf("child exited with status %d\n", status);
64 if(WIFSIGNALED(status) && WCOREDUMP(status)){
65 printf("got a core dump\n");
66 char *core_name = malloc(20);
67 sprintf(core_name,"core_%d", pair);
68 rename("core", core_name);
76 int reached(xbt_state_t st){
78 raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
81 if(xbt_dynar_is_empty(reached_pairs)){
89 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
90 MC_take_snapshot_liveness(sn);
92 xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
96 /* Get values of propositional symbols */
97 unsigned int cursor = 0;
98 xbt_propositional_symbol_t ps = NULL;
99 xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps){
100 f = (int_f_void_t)ps->function;
102 xbt_dynar_push_as(prop_ato, int, res);
106 mc_pair_reached_t pair_test = NULL;
108 //xbt_dict_t current_rdv_points = SIMIX_get_rdv_points();
110 xbt_dynar_foreach(reached_pairs, cursor, pair_test){
111 XBT_INFO("Pair reached #%d", pair_test->nb);
112 if(automaton_state_compare(pair_test->automaton_state, st) == 0){
113 if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
114 //XBT_INFO("Rdv points size %d - %d", xbt_dict_length(pair_test->rdv_points), xbt_dict_length(current_rdv_points));
115 //if(xbt_dict_length(pair_test->rdv_points) == xbt_dict_length(current_rdv_points)){
116 //if(rdv_points_compare(pair_test->rdv_points, current_rdv_points) == 0){
117 if(snapshot_compare(pair_test->system_state, sn) == 0){
119 MC_free_snapshot(sn);
120 xbt_dynar_reset(prop_ato);
133 XBT_INFO("Different size of rdv points (%d - %d)",xbt_dict_length(pair_test->rdv_points), xbt_dict_length(current_rdv_points) );
136 XBT_INFO("Different values of propositional symbols");
139 XBT_INFO("Different automaton state");
143 MC_free_snapshot(sn);
144 xbt_dynar_reset(prop_ato);
158 int rdv_points_compare(xbt_dict_t d1, xbt_dict_t d2){ /* d1 = pair_test, d2 = current_pair */
160 xbt_dict_cursor_t cursor_dict = NULL;
163 smx_rdv_t rdv1, rdv2;
164 xbt_fifo_item_t item1, item2;
165 smx_action_t action1, action2;
166 xbt_fifo_item_t item_req1, item_req2;
167 smx_simcall_t req1, req2;
171 xbt_dict_foreach(d1, cursor_dict, key, data){
172 rdv1 = (smx_rdv_t)data;
173 rdv2 = xbt_dict_get_or_null(d2, rdv1->name);
175 XBT_INFO("Rdv point unknown");
178 if(xbt_fifo_size(rdv1->comm_fifo) != xbt_fifo_size(rdv2->comm_fifo)){
179 XBT_INFO("Different total of actions in mailbox \"%s\" (%d - %d)", rdv1->name, xbt_fifo_size(rdv1->comm_fifo),xbt_fifo_size(rdv2->comm_fifo) );
183 XBT_INFO("Total of actions in mailbox \"%s\" : %d", rdv1->name, xbt_fifo_size(rdv1->comm_fifo));
185 item1 = xbt_fifo_get_first_item(rdv1->comm_fifo);
186 item2 = xbt_fifo_get_first_item(rdv2->comm_fifo);
188 while(i<xbt_fifo_size(rdv1->comm_fifo)){
189 action1 = (smx_action_t) xbt_fifo_get_item_content(item1);
190 action2 = (smx_action_t) xbt_fifo_get_item_content(item2);
192 if(action1->type != action2->type){
193 XBT_INFO("Different type of action");
197 if(action1->state != action2->state){
198 XBT_INFO("Different state of action");
202 if(xbt_fifo_size(action1->simcalls) != xbt_fifo_size(action2->simcalls)){
203 XBT_INFO("Different size of simcall list (%d - %d", xbt_fifo_size(action1->simcalls), xbt_fifo_size(action2->simcalls));
207 item_req1 = xbt_fifo_get_first_item(action1->simcalls);
208 item_req2 = xbt_fifo_get_first_item(action2->simcalls);
210 while(j<xbt_fifo_size(action1->simcalls)){
212 req1 = (smx_simcall_t) xbt_fifo_get_item_content(item_req1);
213 req2 = (smx_simcall_t) xbt_fifo_get_item_content(item_req2);
215 if(req1->call != req2->call){
216 XBT_INFO("Different simcall call in simcalls of action (%d - %d)", (int)req1->call, (int)req2->call);
219 if(req1->issuer->pid != req2->issuer->pid){
220 XBT_INFO("Different simcall issuer in simcalls of action (%lu- %lu)", req1->issuer->pid, req2->issuer->pid);
224 item_req1 = xbt_fifo_get_next_item(item_req1);
225 item_req2 = xbt_fifo_get_next_item(item_req2);
231 switch(action1->type){
232 case 0: /* execution */
233 case 1: /* parallel execution */
234 if(strcmp(action1->execution.host->name, action2->execution.host->name) != 0)
238 if(action1->comm.type != action2->comm.type)
240 //XBT_INFO("Type of comm : %d", action1->comm.type);
242 switch(action1->comm.type){
244 if(action1->comm.src_proc->pid != action2->comm.src_proc->pid)
246 if(strcmp(action1->comm.src_proc->smx_host->name, action2->comm.src_proc->smx_host->name) != 0)
249 case 1: /* RECEIVE */
250 if(action1->comm.dst_proc->pid != action2->comm.dst_proc->pid)
252 if(strcmp(action1->comm.dst_proc->smx_host->name, action2->comm.dst_proc->smx_host->name) != 0)
256 if(action1->comm.src_proc->pid != action2->comm.src_proc->pid)
258 if(strcmp(action1->comm.src_proc->smx_host->name, action2->comm.src_proc->smx_host->name) != 0)
260 if(action1->comm.dst_proc->pid != action2->comm.dst_proc->pid)
262 if(strcmp(action1->comm.dst_proc->smx_host->name, action2->comm.dst_proc->smx_host->name) != 0)
266 if(action1->comm.src_proc->pid != action2->comm.src_proc->pid)
268 if(strcmp(action1->comm.src_proc->smx_host->name, action2->comm.src_proc->smx_host->name) != 0)
270 if(action1->comm.dst_proc->pid != action2->comm.dst_proc->pid)
272 if(strcmp(action1->comm.dst_proc->smx_host->name, action2->comm.dst_proc->smx_host->name) != 0)
276 } /* end of switch on type of comm */
278 if(action1->comm.refcount != action2->comm.refcount)
280 if(action1->comm.detached != action2->comm.detached)
282 if(action1->comm.rate != action2->comm.rate)
284 if(action1->comm.task_size != action2->comm.task_size)
286 if(action1->comm.src_buff != action2->comm.src_buff)
288 if(action1->comm.dst_buff != action2->comm.dst_buff)
290 if(action1->comm.src_data != action2->comm.src_data)
292 if(action1->comm.dst_data != action2->comm.dst_data)
297 if(strcmp(action1->sleep.host->name, action2->sleep.host->name) != 0)
300 case 4: /* synchro */
307 item1 = xbt_fifo_get_next_item(item1);
308 item2 = xbt_fifo_get_next_item(item2);
319 void set_pair_reached(xbt_state_t st){
321 raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
325 mc_pair_reached_t pair = NULL;
326 pair = xbt_new0(s_mc_pair_reached_t, 1);
327 pair->nb = xbt_dynar_length(reached_pairs) + 1;
328 pair->automaton_state = st;
329 pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
330 pair->system_state = xbt_new0(s_mc_snapshot_t, 1);
331 //pair->rdv_points = xbt_dict_new();
332 MC_take_snapshot_liveness(pair->system_state);
334 /* Get values of propositional symbols */
335 unsigned int cursor = 0;
336 xbt_propositional_symbol_t ps = NULL;
340 xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps){
341 f = (int_f_void_t)ps->function;
343 xbt_dynar_push_as(pair->prop_ato, int, res);
346 /*xbt_dict_t rdv_points = SIMIX_get_rdv_points();
348 xbt_dict_cursor_t cursor_dict = NULL;
351 xbt_fifo_item_t item;
354 xbt_dict_foreach(rdv_points, cursor_dict, key, data){
355 smx_rdv_t new_rdv = xbt_new0(s_smx_rvpoint_t, 1);
356 new_rdv->name = strdup(((smx_rdv_t)data)->name);
357 new_rdv->comm_fifo = xbt_fifo_new();
358 xbt_fifo_foreach(((smx_rdv_t)data)->comm_fifo, item, action, smx_action_t) {
359 smx_action_t a = xbt_new0(s_smx_action_t, 1);
360 memcpy(a, action, sizeof(s_smx_action_t));
361 xbt_fifo_push(new_rdv->comm_fifo, a);
362 XBT_INFO("New action (type = %d, state = %d) in mailbox \"%s\"", action->type, action->state, key);
364 XBT_INFO("Type of communication : %d, Ref count = %d", action->comm.type, action->comm.refcount);
366 //new_rdv->comm_fifo = xbt_fifo_copy(((smx_rdv_t)data)->comm_fifo);
367 xbt_dict_set(pair->rdv_points, new_rdv->name, new_rdv, NULL);
370 xbt_dynar_push(reached_pairs, &pair);
379 create_dump(xbt_dynar_length(reached_pairs));
384 int reached_hash(xbt_state_t st){
386 raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
388 if(xbt_dynar_is_empty(reached_pairs_hash)){
396 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
397 MC_take_snapshot_liveness(sn);
400 unsigned int hash_regions[sn->num_reg];
401 for(j=0; j<sn->num_reg; j++){
402 hash_regions[j] = hash_region(sn->regions[j]->data, sn->regions[j]->size);
406 /* Get values of propositional symbols */
407 xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
408 unsigned int cursor = 0;
409 xbt_propositional_symbol_t ps = NULL;
413 xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps){
414 f = (int_f_void_t)ps->function;
416 xbt_dynar_push_as(prop_ato, int, res);
419 mc_pair_reached_hash_t pair_test = NULL;
425 xbt_dynar_foreach(reached_pairs_hash, cursor, pair_test){
427 if(automaton_state_compare(pair_test->automaton_state, st) == 0){
428 if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
429 for(j=0 ; j< sn->num_reg ; j++){
430 if(hash_regions[j] != pair_test->hash_regions[j]){
434 if(region_diff == 0){
435 MC_free_snapshot(sn);
436 xbt_dynar_reset(prop_ato);
447 XBT_INFO("Different snapshot");
450 XBT_INFO("Different values of propositional symbols");
453 XBT_INFO("Different automaton state");
459 MC_free_snapshot(sn);
460 xbt_dynar_reset(prop_ato);
474 void set_pair_reached_hash(xbt_state_t st){
476 raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
480 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
481 MC_take_snapshot_liveness(sn);
483 mc_pair_reached_hash_t pair = NULL;
484 pair = xbt_new0(s_mc_pair_reached_hash_t, 1);
485 pair->automaton_state = st;
486 pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
487 pair->hash_regions = malloc(sizeof(unsigned int) * sn->num_reg);
491 for(i=0 ; i< sn->num_reg ; i++){
492 pair->hash_regions[i] = hash_region(sn->regions[i]->data, sn->regions[i]->size);
495 /* Get values of propositional symbols */
496 unsigned int cursor = 0;
497 xbt_propositional_symbol_t ps = NULL;
501 xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps){
502 f = (int_f_void_t)ps->function;
504 xbt_dynar_push_as(pair->prop_ato, int, res);
507 xbt_dynar_push(reached_pairs_hash, &pair);
509 MC_free_snapshot(sn);
521 int visited(xbt_state_t st, int sc){
523 raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
525 if(xbt_dynar_is_empty(visited_pairs)){
533 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
534 MC_take_snapshot_liveness(sn);
536 xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
538 /* Get values of propositional symbols */
539 unsigned int cursor = 0;
540 xbt_propositional_symbol_t ps = NULL;
544 xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps){
545 f = (int_f_void_t)ps->function;
547 xbt_dynar_push_as(prop_ato, int, res);
551 mc_pair_visited_t pair_test = NULL;
553 xbt_dynar_foreach(visited_pairs, cursor, pair_test){
554 if(pair_test->search_cycle == sc) {
555 if(automaton_state_compare(pair_test->automaton_state, st) == 0){
556 if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
557 if(snapshot_compare(pair_test->system_state, sn) == 0){
559 MC_free_snapshot(sn);
560 xbt_dynar_reset(prop_ato);
572 XBT_INFO("Different snapshot");
575 XBT_INFO("Different values of propositional symbols");
578 XBT_INFO("Different automaton state");
581 XBT_INFO("Different value of search_cycle");
586 MC_free_snapshot(sn);
587 xbt_dynar_reset(prop_ato);
602 int visited_hash(xbt_state_t st, int sc){
604 raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
606 if(xbt_dynar_is_empty(visited_pairs_hash)){
614 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
615 MC_take_snapshot_liveness(sn);
618 unsigned int hash_regions[sn->num_reg];
619 for(j=0; j<sn->num_reg; j++){
620 hash_regions[j] = hash_region(sn->regions[j]->data, sn->regions[j]->size);
624 /* Get values of propositional symbols */
625 xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
626 unsigned int cursor = 0;
627 xbt_propositional_symbol_t ps = NULL;
631 xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps){
632 f = (int_f_void_t)ps->function;
634 xbt_dynar_push_as(prop_ato, int, res);
637 mc_pair_visited_hash_t pair_test = NULL;
642 xbt_dynar_foreach(visited_pairs_hash, cursor, pair_test){
644 if(pair_test->search_cycle == sc) {
645 if(automaton_state_compare(pair_test->automaton_state, st) == 0){
646 if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
647 for(j=0 ; j< sn->num_reg ; j++){
648 if(hash_regions[j] != pair_test->hash_regions[j]){
652 if(region_diff == 0){
653 MC_free_snapshot(sn);
654 xbt_dynar_reset(prop_ato);
665 //XBT_INFO("Different snapshot");
668 //XBT_INFO("Different values of propositional symbols");
671 //XBT_INFO("Different automaton state");
674 //XBT_INFO("Different value of search_cycle");
680 MC_free_snapshot(sn);
681 xbt_dynar_reset(prop_ato);
695 void set_pair_visited_hash(xbt_state_t st, int sc){
697 raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
701 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
702 MC_take_snapshot_liveness(sn);
704 mc_pair_visited_hash_t pair = NULL;
705 pair = xbt_new0(s_mc_pair_visited_hash_t, 1);
706 pair->automaton_state = st;
707 pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
708 pair->search_cycle = sc;
709 pair->hash_regions = malloc(sizeof(unsigned int) * sn->num_reg);
713 for(i=0 ; i< sn->num_reg ; i++){
714 pair->hash_regions[i] = hash_region(sn->regions[i]->data, sn->regions[i]->size);
717 /* Get values of propositional symbols */
718 unsigned int cursor = 0;
719 xbt_propositional_symbol_t ps = NULL;
723 xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps){
724 f = (int_f_void_t)ps->function;
726 xbt_dynar_push_as(pair->prop_ato, int, res);
729 xbt_dynar_push(visited_pairs_hash, &pair);
731 MC_free_snapshot(sn);
742 void set_pair_visited(xbt_state_t st, int sc){
744 raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
748 mc_pair_visited_t pair = NULL;
749 pair = xbt_new0(s_mc_pair_visited_t, 1);
750 pair->automaton_state = st;
751 pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
752 pair->search_cycle = sc;
753 pair->system_state = xbt_new0(s_mc_snapshot_t, 1);
754 MC_take_snapshot_liveness(pair->system_state);
757 /* Get values of propositional symbols */
758 unsigned int cursor = 0;
759 xbt_propositional_symbol_t ps = NULL;
763 xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps){
764 f = (int_f_void_t)ps->function;
766 xbt_dynar_push_as(pair->prop_ato, int, res);
769 xbt_dynar_push(visited_pairs, &pair);
780 void MC_pair_delete(mc_pair_t pair){
781 xbt_free(pair->graph_state->proc_status);
782 xbt_free(pair->graph_state);
788 int MC_automaton_evaluate_label(xbt_exp_label_t l){
792 int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
793 int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
794 return (left_res || right_res);
797 int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
798 int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
799 return (left_res && right_res);
802 int res = MC_automaton_evaluate_label(l->u.exp_not);
806 unsigned int cursor = 0;
807 xbt_propositional_symbol_t p = NULL;
809 xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, p){
810 if(strcmp(p->pred, l->u.predicat) == 0){
811 f = (int_f_void_t)p->function;
826 /********************* Double-DFS stateless *******************/
828 void MC_pair_stateless_delete(mc_pair_stateless_t pair){
829 xbt_free(pair->graph_state->proc_status);
830 xbt_free(pair->graph_state);
834 mc_pair_stateless_t new_pair_stateless(mc_state_t sg, xbt_state_t st, int r){
835 mc_pair_stateless_t p = NULL;
836 p = xbt_new0(s_mc_pair_stateless_t, 1);
837 p->automaton_state = st;
840 mc_stats_pair->expanded_pairs++;
844 void MC_ddfs_init(void){
846 raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
848 XBT_INFO("**************************************************");
849 XBT_INFO("Double-DFS init");
850 XBT_INFO("**************************************************");
852 mc_pair_stateless_t mc_initial_pair = NULL;
853 mc_state_t initial_graph_state = NULL;
854 smx_process_t process;
857 MC_wait_for_requests();
861 initial_graph_state = MC_state_pair_new();
862 xbt_swag_foreach(process, simix_global->process_list){
863 if(MC_process_is_enabled(process)){
864 MC_state_interleave_process(initial_graph_state, process);
868 reached_pairs = xbt_dynar_new(sizeof(mc_pair_reached_t), NULL);
869 //reached_pairs_hash = xbt_dynar_new(sizeof(mc_pair_reached_hash_t), NULL);
870 //visited_pairs = xbt_dynar_new(sizeof(mc_pair_visited_t), NULL);
871 //visited_pairs_hash = xbt_dynar_new(sizeof(mc_pair_visited_hash_t), NULL);
872 successors = xbt_dynar_new(sizeof(mc_pair_stateless_t), NULL);
874 /* Save the initial state */
875 initial_snapshot_liveness = xbt_new0(s_mc_snapshot_t, 1);
876 MC_take_snapshot_liveness(initial_snapshot_liveness);
880 unsigned int cursor = 0;
883 xbt_dynar_foreach(_mc_property_automaton->states, cursor, state){
884 if(state->type == -1){
887 mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
888 xbt_fifo_unshift(mc_stack_liveness, mc_initial_pair);
892 MC_restore_snapshot(initial_snapshot_liveness);
899 if(state->type == 2){
902 mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
903 xbt_fifo_unshift(mc_stack_liveness, mc_initial_pair);
906 set_pair_reached(state);
907 //set_pair_reached_hash(state);
910 MC_restore_snapshot(initial_snapshot_liveness);
929 void MC_ddfs(int search_cycle){
931 raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
933 smx_process_t process;
934 mc_pair_stateless_t current_pair = NULL;
936 if(xbt_fifo_size(mc_stack_liveness) == 0)
940 /* Get current pair */
941 current_pair = (mc_pair_stateless_t)xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack_liveness));
943 /* Update current state in buchi automaton */
944 _mc_property_automaton->current_state = current_pair->automaton_state;
947 XBT_INFO("********************* ( Depth = %d, search_cycle = %d )", xbt_fifo_size(mc_stack_liveness), search_cycle);
948 XBT_INFO("Pair : graph=%p, automaton=%p(%s), %u interleave", current_pair->graph_state, current_pair->automaton_state, current_pair->automaton_state->id, MC_state_interleave_size(current_pair->graph_state));
950 mc_stats_pair->visited_pairs++;
955 mc_state_t next_graph_state = NULL;
956 smx_simcall_t req = NULL;
959 xbt_transition_t transition_succ;
960 unsigned int cursor = 0;
963 mc_pair_stateless_t next_pair = NULL;
964 mc_pair_stateless_t pair_succ;
966 if(xbt_fifo_size(mc_stack_liveness) < MAX_DEPTH_LIVENESS){
968 //set_pair_visited(current_pair->automaton_state, search_cycle);
969 //set_pair_visited_hash(current_pair->automaton_state, search_cycle);
971 //XBT_INFO("Visited pairs : %lu", xbt_dynar_length(visited_pairs));
972 //XBT_INFO("Visited pairs : %lu", xbt_dynar_length(visited_pairs_hash));
974 if(current_pair->requests > 0){
976 while((req = MC_state_get_request(current_pair->graph_state, &value)) != NULL){
978 /* Debug information */
980 req_str = MC_request_to_string(req, value);
981 XBT_INFO("Execute: %s", req_str);
984 MC_state_set_executed_request(current_pair->graph_state, req, value);
986 /* Answer the request */
987 SIMIX_simcall_pre(req, value);
989 /* Wait for requests (schedules processes) */
990 MC_wait_for_requests();
995 /* Create the new expanded graph_state */
996 next_graph_state = MC_state_pair_new();
998 /* Get enabled process and insert it in the interleave set of the next graph_state */
999 xbt_swag_foreach(process, simix_global->process_list){
1000 if(MC_process_is_enabled(process)){
1001 MC_state_interleave_process(next_graph_state, process);
1005 xbt_dynar_reset(successors);
1011 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
1013 res = MC_automaton_evaluate_label(transition_succ->label);
1015 if(res == 1){ // enabled transition in automaton
1017 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
1018 xbt_dynar_push(successors, &next_pair);
1026 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
1028 res = MC_automaton_evaluate_label(transition_succ->label);
1030 if(res == 2){ // true transition in automaton
1032 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
1033 xbt_dynar_push(successors, &next_pair);
1041 xbt_dynar_foreach(successors, cursor, pair_succ){
1043 if(search_cycle == 1){
1045 if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){
1047 if(reached(pair_succ->automaton_state)){
1048 //if(reached_hash(pair_succ->automaton_state)){
1050 XBT_INFO("Next pair (depth = %d, %u interleave) already reached !", xbt_fifo_size(mc_stack_liveness) + 1, MC_state_interleave_size(pair_succ->graph_state));
1052 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1053 XBT_INFO("| ACCEPTANCE CYCLE |");
1054 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1055 XBT_INFO("Counter-example that violates formula :");
1056 MC_show_stack_liveness(mc_stack_liveness);
1057 MC_dump_stack_liveness(mc_stack_liveness);
1058 MC_print_statistics_pairs(mc_stats_pair);
1063 XBT_INFO("Next pair (depth =%d) -> Acceptance pair : graph=%p, automaton=%p(%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->graph_state, pair_succ->automaton_state, pair_succ->automaton_state->id);
1065 set_pair_reached(pair_succ->automaton_state);
1066 //set_pair_reached_hash(pair_succ->automaton_state);
1068 XBT_INFO("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1069 //XBT_INFO("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1072 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1075 MC_ddfs(search_cycle);
1081 //if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1082 //if(!visited(pair_succ->automaton_state, search_cycle)){
1085 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1088 MC_ddfs(search_cycle);
1092 XBT_INFO("Next pair already visited ! ");
1100 if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
1102 XBT_INFO("Next pair (depth =%d) -> Acceptance pair : graph=%p, automaton=%p(%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->graph_state, pair_succ->automaton_state, pair_succ->automaton_state->id);
1104 set_pair_reached(pair_succ->automaton_state);
1105 //set_pair_reached_hash(pair_succ->automaton_state);
1109 XBT_INFO("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1110 //XBT_INFO("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1114 //if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1115 //if(!visited(pair_succ->automaton_state, search_cycle)){
1118 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1121 MC_ddfs(search_cycle);
1125 XBT_INFO("Next pair already visited ! ");
1132 /* Restore system before checking others successors */
1133 if(cursor != (xbt_dynar_length(successors) - 1))
1134 MC_replay_liveness(mc_stack_liveness, 1);
1139 if(MC_state_interleave_size(current_pair->graph_state) > 0){
1140 XBT_INFO("Backtracking to depth %d", xbt_fifo_size(mc_stack_liveness));
1141 MC_replay_liveness(mc_stack_liveness, 0);
1146 }else{ /*No request to execute, search evolution in Büchi automaton */
1150 /* Create the new expanded graph_state */
1151 next_graph_state = MC_state_pair_new();
1153 xbt_dynar_reset(successors);
1159 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
1161 res = MC_automaton_evaluate_label(transition_succ->label);
1163 if(res == 1){ // enabled transition in automaton
1165 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
1166 xbt_dynar_push(successors, &next_pair);
1174 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
1176 res = MC_automaton_evaluate_label(transition_succ->label);
1178 if(res == 2){ // true transition in automaton
1180 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
1181 xbt_dynar_push(successors, &next_pair);
1189 xbt_dynar_foreach(successors, cursor, pair_succ){
1191 if(search_cycle == 1){
1193 if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){
1195 if(reached(pair_succ->automaton_state)){
1196 //if(reached_hash(pair_succ->automaton_state)){
1198 XBT_INFO("Next pair (depth = %d) already reached !", xbt_fifo_size(mc_stack_liveness) + 1);
1200 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1201 XBT_INFO("| ACCEPTANCE CYCLE |");
1202 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1203 XBT_INFO("Counter-example that violates formula :");
1204 MC_show_stack_liveness(mc_stack_liveness);
1205 MC_dump_stack_liveness(mc_stack_liveness);
1206 MC_print_statistics_pairs(mc_stats_pair);
1211 XBT_INFO("Next pair (depth = %d) -> Acceptance pair : graph=%p, automaton=%p(%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->graph_state, pair_succ->automaton_state, pair_succ->automaton_state->id);
1213 set_pair_reached(pair_succ->automaton_state);
1214 //set_pair_reached_hash(pair_succ->automaton_state);
1216 XBT_INFO("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1217 //XBT_INFO("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1220 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1223 MC_ddfs(search_cycle);
1229 //if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1230 //if(!visited(pair_succ->automaton_state, search_cycle)){
1233 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1236 MC_ddfs(search_cycle);
1240 XBT_INFO("Next pair already visited ! ");
1248 if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
1250 set_pair_reached(pair_succ->automaton_state);
1251 //set_pair_reached_hash(pair_succ->automaton_state);
1255 XBT_INFO("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1256 //XBT_INFO("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1260 //if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1261 //if(!visited(pair_succ->automaton_state, search_cycle)){
1264 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1267 MC_ddfs(search_cycle);
1271 XBT_INFO("Next pair already visited ! ");
1277 /* Restore system before checking others successors */
1278 if(cursor != xbt_dynar_length(successors) - 1)
1279 MC_replay_liveness(mc_stack_liveness, 1);
1288 XBT_INFO("Max depth reached");
1292 if(xbt_fifo_size(mc_stack_liveness) == MAX_DEPTH_LIVENESS ){
1293 XBT_INFO("Pair (graph=%p, automaton =%p, search_cycle = %d, depth = %d) shifted in stack, maximum depth reached", current_pair->graph_state, current_pair->automaton_state, search_cycle, xbt_fifo_size(mc_stack_liveness) );
1295 XBT_INFO("Pair (graph=%p, automaton =%p, search_cycle = %d, depth = %d) shifted in stack", current_pair->graph_state, current_pair->automaton_state, search_cycle, xbt_fifo_size(mc_stack_liveness) );
1300 xbt_fifo_shift(mc_stack_liveness);
1301 if((current_pair->automaton_state->type == 1) || (current_pair->automaton_state->type == 2)){
1302 xbt_dynar_pop(reached_pairs, NULL);
1303 //xbt_dynar_pop(reached_pairs_hash, NULL);