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"
9 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_liveness, mc,
10 "Logging specific to algorithms for liveness properties verification");
12 xbt_dynar_t reached_pairs;
13 xbt_dynar_t reached_pairs_hash;
14 xbt_dynar_t visited_pairs;
15 xbt_dynar_t visited_pairs_hash;
16 xbt_dynar_t successors;
18 xbt_dynar_t hosts_table;
21 /* fast implementation of djb2 algorithm */
22 unsigned int hash_region(char *str, int str_len){
25 register unsigned int hash = 5381;
29 hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
36 int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
39 if(s1->num_reg != s2->num_reg){
40 XBT_DEBUG("Different num_reg (s1 = %u, s2 = %u)", s1->num_reg, s2->num_reg);
47 for(i=0 ; i< s1->num_reg ; i++){
49 if(s1->regions[i]->type != s2->regions[i]->type){
50 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
51 XBT_DEBUG("Different type of region");
58 switch(s1->regions[i]->type){
60 if(s1->regions[i]->size != s2->regions[i]->size){
61 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
62 XBT_DEBUG("Different size of heap (s1 = %zu, s2 = %zu)", s1->regions[i]->size, s2->regions[i]->size);
68 if(s1->regions[i]->start_addr != s2->regions[i]->start_addr){
69 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
70 XBT_DEBUG("Different start addr of heap (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr);
76 if(mmalloc_compare_heap(s1->regions[i]->data, s2->regions[i]->data)){
77 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
78 XBT_DEBUG("Different heap (mmalloc_compare)");
86 if(s1->regions[i]->size != s2->regions[i]->size){
87 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
88 XBT_DEBUG("Different size of libsimgrid (s1 = %zu, s2 = %zu)", s1->regions[i]->size, s2->regions[i]->size);
94 if(s1->regions[i]->start_addr != s2->regions[i]->start_addr){
95 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
96 XBT_DEBUG("Different start addr of libsimgrid (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr);
102 if(memcmp(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){
103 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
104 XBT_DEBUG("Different memcmp for data in libsimgrid");
105 XBT_DEBUG("Size : %zu", s1->regions[i]->size);
122 int reached(xbt_state_t st){
125 if(xbt_dynar_is_empty(reached_pairs)){
133 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
134 MC_take_snapshot_liveness(sn);
136 xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
140 /* Get values of propositional symbols */
141 unsigned int cursor = 0;
142 xbt_propositional_symbol_t ps = NULL;
143 xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
144 f = (int_f_void_t)ps->function;
146 xbt_dynar_push_as(prop_ato, int, res);
150 mc_pair_reached_t pair_test = NULL;
152 //xbt_dict_t current_rdv_points = SIMIX_get_rdv_points();
154 xbt_dynar_foreach(reached_pairs, cursor, pair_test){
155 XBT_DEBUG("Pair reached #%u", cursor+1);
156 if(automaton_state_compare(pair_test->automaton_state, st) == 0){
157 if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
158 //XBT_DEBUG("Rdv points size %d - %d", xbt_dict_length(pair_test->rdv_points), xbt_dict_length(current_rdv_points));
159 //if(xbt_dict_length(pair_test->rdv_points) == xbt_dict_length(current_rdv_points)){
160 //if(rdv_points_compare(pair_test->rdv_points, current_rdv_points) == 0){
161 if(snapshot_compare(pair_test->system_state, sn) == 0){
162 MC_free_snapshot(sn);
163 xbt_dynar_reset(prop_ato);
170 XBT_DEBUG("Different size of rdv points (%d - %d)",xbt_dict_length(pair_test->rdv_points), xbt_dict_length(current_rdv_points) );
173 XBT_DEBUG("Different values of propositional symbols");
176 XBT_DEBUG("Different automaton state");
180 MC_free_snapshot(sn);
181 xbt_dynar_reset(prop_ato);
189 int rdv_points_compare(xbt_dict_t d1, xbt_dict_t d2){ /* d1 = pair_test, d2 = current_pair */
191 xbt_dict_cursor_t cursor_dict = NULL;
194 smx_rdv_t rdv1, rdv2;
195 xbt_fifo_item_t item1, item2;
196 smx_action_t action1, action2;
197 xbt_fifo_item_t item_req1, item_req2;
198 smx_simcall_t req1, req2;
202 xbt_dict_foreach(d1, cursor_dict, key, data){
203 rdv1 = (smx_rdv_t)data;
204 rdv2 = xbt_dict_get_or_null(d2, rdv1->name);
206 XBT_DEBUG("Rdv point unknown");
209 if(xbt_fifo_size(rdv1->comm_fifo) != xbt_fifo_size(rdv2->comm_fifo)){
210 XBT_DEBUG("Different total of actions in mailbox \"%s\" (%d - %d)", rdv1->name, xbt_fifo_size(rdv1->comm_fifo),xbt_fifo_size(rdv2->comm_fifo) );
214 XBT_DEBUG("Total of actions in mailbox \"%s\" : %d", rdv1->name, xbt_fifo_size(rdv1->comm_fifo));
216 item1 = xbt_fifo_get_first_item(rdv1->comm_fifo);
217 item2 = xbt_fifo_get_first_item(rdv2->comm_fifo);
219 while(i<xbt_fifo_size(rdv1->comm_fifo)){
220 action1 = (smx_action_t) xbt_fifo_get_item_content(item1);
221 action2 = (smx_action_t) xbt_fifo_get_item_content(item2);
223 if(action1->type != action2->type){
224 XBT_DEBUG("Different type of action");
228 if(action1->state != action2->state){
229 XBT_DEBUG("Different state of action");
233 if(xbt_fifo_size(action1->simcalls) != xbt_fifo_size(action2->simcalls)){
234 XBT_DEBUG("Different size of simcall list (%d - %d", xbt_fifo_size(action1->simcalls), xbt_fifo_size(action2->simcalls));
238 item_req1 = xbt_fifo_get_first_item(action1->simcalls);
239 item_req2 = xbt_fifo_get_first_item(action2->simcalls);
241 while(j<xbt_fifo_size(action1->simcalls)){
243 req1 = (smx_simcall_t) xbt_fifo_get_item_content(item_req1);
244 req2 = (smx_simcall_t) xbt_fifo_get_item_content(item_req2);
246 if(req1->call != req2->call){
247 XBT_DEBUG("Different simcall call in simcalls of action (%d - %d)", (int)req1->call, (int)req2->call);
250 if(req1->issuer->pid != req2->issuer->pid){
251 XBT_DEBUG("Different simcall issuer in simcalls of action (%lu- %lu)", req1->issuer->pid, req2->issuer->pid);
255 item_req1 = xbt_fifo_get_next_item(item_req1);
256 item_req2 = xbt_fifo_get_next_item(item_req2);
262 switch(action1->type){
263 case 0: /* execution */
264 case 1: /* parallel execution */
265 if(strcmp(action1->execution.host->name, action2->execution.host->name) != 0)
269 if(action1->comm.type != action2->comm.type)
271 //XBT_DEBUG("Type of comm : %d", action1->comm.type);
273 switch(action1->comm.type){
275 if(action1->comm.src_proc->pid != action2->comm.src_proc->pid)
277 if(strcmp(action1->comm.src_proc->smx_host->name, action2->comm.src_proc->smx_host->name) != 0)
280 case 1: /* RECEIVE */
281 if(action1->comm.dst_proc->pid != action2->comm.dst_proc->pid)
283 if(strcmp(action1->comm.dst_proc->smx_host->name, action2->comm.dst_proc->smx_host->name) != 0)
287 if(action1->comm.src_proc->pid != action2->comm.src_proc->pid)
289 if(strcmp(action1->comm.src_proc->smx_host->name, action2->comm.src_proc->smx_host->name) != 0)
291 if(action1->comm.dst_proc->pid != action2->comm.dst_proc->pid)
293 if(strcmp(action1->comm.dst_proc->smx_host->name, action2->comm.dst_proc->smx_host->name) != 0)
297 if(action1->comm.src_proc->pid != action2->comm.src_proc->pid)
299 if(strcmp(action1->comm.src_proc->smx_host->name, action2->comm.src_proc->smx_host->name) != 0)
301 if(action1->comm.dst_proc->pid != action2->comm.dst_proc->pid)
303 if(strcmp(action1->comm.dst_proc->smx_host->name, action2->comm.dst_proc->smx_host->name) != 0)
307 } /* end of switch on type of comm */
309 if(action1->comm.refcount != action2->comm.refcount)
311 if(action1->comm.detached != action2->comm.detached)
313 if(action1->comm.rate != action2->comm.rate)
315 if(action1->comm.task_size != action2->comm.task_size)
317 if(action1->comm.src_buff != action2->comm.src_buff)
319 if(action1->comm.dst_buff != action2->comm.dst_buff)
321 if(action1->comm.src_data != action2->comm.src_data)
323 if(action1->comm.dst_data != action2->comm.dst_data)
328 if(strcmp(action1->sleep.host->name, action2->sleep.host->name) != 0)
331 case 4: /* synchro */
338 item1 = xbt_fifo_get_next_item(item1);
339 item2 = xbt_fifo_get_next_item(item2);
350 void set_pair_reached(xbt_state_t st){
355 mc_pair_reached_t pair = NULL;
356 pair = xbt_new0(s_mc_pair_reached_t, 1);
357 pair->automaton_state = st;
358 pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
359 pair->system_state = xbt_new0(s_mc_snapshot_t, 1);
360 //pair->rdv_points = xbt_dict_new();
361 MC_take_snapshot_liveness(pair->system_state);
363 /* Get values of propositional symbols */
364 unsigned int cursor = 0;
365 xbt_propositional_symbol_t ps = NULL;
369 xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
370 f = (int_f_void_t)ps->function;
372 xbt_dynar_push_as(pair->prop_ato, int, res);
375 /*xbt_dict_t rdv_points = SIMIX_get_rdv_points();
377 xbt_dict_cursor_t cursor_dict = NULL;
380 xbt_fifo_item_t item;
383 xbt_dict_foreach(rdv_points, cursor_dict, key, data){
384 smx_rdv_t new_rdv = xbt_new0(s_smx_rvpoint_t, 1);
385 new_rdv->name = strdup(((smx_rdv_t)data)->name);
386 new_rdv->comm_fifo = xbt_fifo_new();
387 xbt_fifo_foreach(((smx_rdv_t)data)->comm_fifo, item, action, smx_action_t) {
388 smx_action_t a = xbt_new0(s_smx_action_t, 1);
389 memcpy(a, action, sizeof(s_smx_action_t));
390 xbt_fifo_push(new_rdv->comm_fifo, a);
391 XBT_DEBUG("New action (type = %d, state = %d) in mailbox \"%s\"", action->type, action->state, key);
393 XBT_DEBUG("Type of communication : %d, Ref count = %d", action->comm.type, action->comm.refcount);
395 //new_rdv->comm_fifo = xbt_fifo_copy(((smx_rdv_t)data)->comm_fifo);
396 xbt_dict_set(pair->rdv_points, new_rdv->name, new_rdv, NULL);
399 xbt_dynar_push(reached_pairs, &pair);
406 int reached_hash(xbt_state_t st){
409 if(xbt_dynar_is_empty(reached_pairs_hash)){
417 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
418 MC_take_snapshot_liveness(sn);
421 unsigned int hash_regions[sn->num_reg];
422 for(j=0; j<sn->num_reg; j++){
423 hash_regions[j] = hash_region(sn->regions[j]->data, sn->regions[j]->size);
427 /* Get values of propositional symbols */
428 xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
429 unsigned int cursor = 0;
430 xbt_propositional_symbol_t ps = NULL;
434 xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
435 f = (int_f_void_t)ps->function;
437 xbt_dynar_push_as(prop_ato, int, res);
440 mc_pair_reached_hash_t pair_test = NULL;
446 xbt_dynar_foreach(reached_pairs_hash, cursor, pair_test){
448 if(automaton_state_compare(pair_test->automaton_state, st) == 0){
449 if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
450 for(j=0 ; j< sn->num_reg ; j++){
451 if(hash_regions[j] != pair_test->hash_regions[j]){
455 if(region_diff == 0){
456 MC_free_snapshot(sn);
457 xbt_dynar_reset(prop_ato);
462 XBT_DEBUG("Different snapshot");
465 XBT_DEBUG("Different values of propositional symbols");
468 XBT_DEBUG("Different automaton state");
474 MC_free_snapshot(sn);
475 xbt_dynar_reset(prop_ato);
483 void set_pair_reached_hash(xbt_state_t st){
487 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
488 MC_take_snapshot_liveness(sn);
490 mc_pair_reached_hash_t pair = NULL;
491 pair = xbt_new0(s_mc_pair_reached_hash_t, 1);
492 pair->automaton_state = st;
493 pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
494 pair->hash_regions = malloc(sizeof(unsigned int) * sn->num_reg);
498 for(i=0 ; i< sn->num_reg ; i++){
499 pair->hash_regions[i] = hash_region(sn->regions[i]->data, sn->regions[i]->size);
502 /* Get values of propositional symbols */
503 unsigned int cursor = 0;
504 xbt_propositional_symbol_t ps = NULL;
508 xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
509 f = (int_f_void_t)ps->function;
511 xbt_dynar_push_as(pair->prop_ato, int, res);
514 xbt_dynar_push(reached_pairs_hash, &pair);
516 MC_free_snapshot(sn);
523 int visited(xbt_state_t st, int sc){
526 if(xbt_dynar_is_empty(visited_pairs)){
534 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
535 MC_take_snapshot_liveness(sn);
537 xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
539 /* Get values of propositional symbols */
540 unsigned int cursor = 0;
541 xbt_propositional_symbol_t ps = NULL;
545 xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
546 f = (int_f_void_t)ps->function;
548 xbt_dynar_push_as(prop_ato, int, res);
552 mc_pair_visited_t pair_test = NULL;
554 xbt_dynar_foreach(visited_pairs, cursor, pair_test){
555 if(pair_test->search_cycle == sc) {
556 if(automaton_state_compare(pair_test->automaton_state, st) == 0){
557 if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
558 if(snapshot_compare(pair_test->system_state, sn) == 0){
560 MC_free_snapshot(sn);
561 xbt_dynar_reset(prop_ato);
568 XBT_DEBUG("Different snapshot");
571 XBT_DEBUG("Different values of propositional symbols");
574 XBT_DEBUG("Different automaton state");
577 XBT_DEBUG("Different value of search_cycle");
582 MC_free_snapshot(sn);
583 xbt_dynar_reset(prop_ato);
592 int visited_hash(xbt_state_t st, int sc){
595 if(xbt_dynar_is_empty(visited_pairs_hash)){
603 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
604 MC_take_snapshot_liveness(sn);
607 unsigned int hash_regions[sn->num_reg];
608 for(j=0; j<sn->num_reg; j++){
609 hash_regions[j] = hash_region(sn->regions[j]->data, sn->regions[j]->size);
613 /* Get values of propositional symbols */
614 xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
615 unsigned int cursor = 0;
616 xbt_propositional_symbol_t ps = NULL;
620 xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
621 f = (int_f_void_t)ps->function;
623 xbt_dynar_push_as(prop_ato, int, res);
626 mc_pair_visited_hash_t pair_test = NULL;
631 xbt_dynar_foreach(visited_pairs_hash, cursor, pair_test){
633 if(pair_test->search_cycle == sc) {
634 if(automaton_state_compare(pair_test->automaton_state, st) == 0){
635 if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
636 for(j=0 ; j< sn->num_reg ; j++){
637 if(hash_regions[j] != pair_test->hash_regions[j]){
641 if(region_diff == 0){
642 MC_free_snapshot(sn);
643 xbt_dynar_reset(prop_ato);
648 XBT_DEBUG("Different snapshot");
651 XBT_DEBUG("Different values of propositional symbols");
654 XBT_DEBUG("Different automaton state");
657 XBT_DEBUG("Different value of search_cycle");
663 MC_free_snapshot(sn);
664 xbt_dynar_reset(prop_ato);
672 void set_pair_visited_hash(xbt_state_t st, int sc){
676 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
677 MC_take_snapshot_liveness(sn);
679 mc_pair_visited_hash_t pair = NULL;
680 pair = xbt_new0(s_mc_pair_visited_hash_t, 1);
681 pair->automaton_state = st;
682 pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
683 pair->search_cycle = sc;
684 pair->hash_regions = malloc(sizeof(unsigned int) * sn->num_reg);
688 for(i=0 ; i< sn->num_reg ; i++){
689 pair->hash_regions[i] = hash_region(sn->regions[i]->data, sn->regions[i]->size);
692 /* Get values of propositional symbols */
693 unsigned int cursor = 0;
694 xbt_propositional_symbol_t ps = NULL;
698 xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
699 f = (int_f_void_t)ps->function;
701 xbt_dynar_push_as(pair->prop_ato, int, res);
704 xbt_dynar_push(visited_pairs_hash, &pair);
706 MC_free_snapshot(sn);
712 void set_pair_visited(xbt_state_t st, int sc){
717 mc_pair_visited_t pair = NULL;
718 pair = xbt_new0(s_mc_pair_visited_t, 1);
719 pair->automaton_state = st;
720 pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
721 pair->search_cycle = sc;
722 pair->system_state = xbt_new0(s_mc_snapshot_t, 1);
723 MC_take_snapshot_liveness(pair->system_state);
726 /* Get values of propositional symbols */
727 unsigned int cursor = 0;
728 xbt_propositional_symbol_t ps = NULL;
732 xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
733 f = (int_f_void_t)ps->function;
735 xbt_dynar_push_as(pair->prop_ato, int, res);
738 xbt_dynar_push(visited_pairs, &pair);
745 void MC_pair_delete(mc_pair_t pair){
746 xbt_free(pair->graph_state->proc_status);
747 xbt_free(pair->graph_state);
753 int MC_automaton_evaluate_label(xbt_exp_label_t l){
757 int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
758 int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
759 return (left_res || right_res);
762 int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
763 int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
764 return (left_res && right_res);
767 int res = MC_automaton_evaluate_label(l->u.exp_not);
771 unsigned int cursor = 0;
772 xbt_propositional_symbol_t p = NULL;
774 xbt_dynar_foreach(automaton->propositional_symbols, cursor, p){
775 if(strcmp(p->pred, l->u.predicat) == 0){
776 f = (int_f_void_t)p->function;
791 /********************* Double-DFS stateless *******************/
793 void MC_pair_stateless_delete(mc_pair_stateless_t pair){
794 xbt_free(pair->graph_state->proc_status);
795 xbt_free(pair->graph_state);
799 mc_pair_stateless_t new_pair_stateless(mc_state_t sg, xbt_state_t st, int r){
800 mc_pair_stateless_t p = NULL;
801 p = xbt_new0(s_mc_pair_stateless_t, 1);
802 p->automaton_state = st;
805 mc_stats_pair->expanded_pairs++;
809 void MC_ddfs_init(void){
811 XBT_DEBUG("**************************************************");
812 XBT_DEBUG("Double-DFS init");
813 XBT_DEBUG("**************************************************");
815 mc_pair_stateless_t mc_initial_pair = NULL;
816 mc_state_t initial_graph_state = NULL;
817 smx_process_t process;
819 MC_wait_for_requests();
823 initial_graph_state = MC_state_pair_new();
824 xbt_swag_foreach(process, simix_global->process_list){
825 if(MC_process_is_enabled(process)){
826 MC_state_interleave_process(initial_graph_state, process);
830 reached_pairs = xbt_dynar_new(sizeof(mc_pair_reached_t), NULL);
831 //reached_pairs_hash = xbt_dynar_new(sizeof(mc_pair_reached_hash_t), NULL);
832 //visited_pairs = xbt_dynar_new(sizeof(mc_pair_visited_t), NULL);
833 visited_pairs_hash = xbt_dynar_new(sizeof(mc_pair_visited_hash_t), NULL);
834 successors = xbt_dynar_new(sizeof(mc_pair_stateless_t), NULL);
836 /* Save the initial state */
837 initial_snapshot_liveness = xbt_new0(s_mc_snapshot_t, 1);
838 MC_take_snapshot_liveness(initial_snapshot_liveness);
842 unsigned int cursor = 0;
845 xbt_dynar_foreach(automaton->states, cursor, state){
846 if(state->type == -1){
849 mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
850 xbt_fifo_unshift(mc_stack_liveness, mc_initial_pair);
854 MC_restore_snapshot(initial_snapshot_liveness);
861 if(state->type == 2){
864 mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
865 xbt_fifo_unshift(mc_stack_liveness, mc_initial_pair);
868 set_pair_reached(state);
869 //set_pair_reached_hash(state);
872 MC_restore_snapshot(initial_snapshot_liveness);
885 void MC_ddfs(int search_cycle){
887 smx_process_t process;
888 mc_pair_stateless_t current_pair = NULL;
890 if(xbt_fifo_size(mc_stack_liveness) == 0)
894 /* Get current pair */
895 current_pair = (mc_pair_stateless_t)xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack_liveness));
897 /* Update current state in buchi automaton */
898 automaton->current_state = current_pair->automaton_state;
901 XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d )", xbt_fifo_size(mc_stack_liveness), search_cycle);
902 XBT_DEBUG("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));
904 mc_stats_pair->visited_pairs++;
909 mc_state_t next_graph_state = NULL;
910 smx_simcall_t req = NULL;
913 xbt_transition_t transition_succ;
914 unsigned int cursor = 0;
917 mc_pair_stateless_t next_pair = NULL;
918 mc_pair_stateless_t pair_succ;
920 if(xbt_fifo_size(mc_stack_liveness) < MAX_DEPTH_LIVENESS){
922 //set_pair_visited(current_pair->automaton_state, search_cycle);
923 set_pair_visited_hash(current_pair->automaton_state, search_cycle);
925 //XBT_DEBUG("Visited pairs : %lu", xbt_dynar_length(visited_pairs));
926 XBT_DEBUG("Visited pairs : %lu", xbt_dynar_length(visited_pairs_hash));
928 if(current_pair->requests > 0){
930 while((req = MC_state_get_request(current_pair->graph_state, &value)) != NULL){
932 /* Debug information */
933 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
934 req_str = MC_request_to_string(req, value);
935 XBT_DEBUG("Execute: %s", req_str);
939 MC_state_set_executed_request(current_pair->graph_state, req, value);
941 /* Answer the request */
942 SIMIX_simcall_pre(req, value);
944 /* Wait for requests (schedules processes) */
945 MC_wait_for_requests();
950 /* Create the new expanded graph_state */
951 next_graph_state = MC_state_pair_new();
953 /* Get enabled process and insert it in the interleave set of the next graph_state */
954 xbt_swag_foreach(process, simix_global->process_list){
955 if(MC_process_is_enabled(process)){
956 MC_state_interleave_process(next_graph_state, process);
960 xbt_dynar_reset(successors);
966 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
968 res = MC_automaton_evaluate_label(transition_succ->label);
970 if(res == 1){ // enabled transition in automaton
972 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
973 xbt_dynar_push(successors, &next_pair);
981 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
983 res = MC_automaton_evaluate_label(transition_succ->label);
985 if(res == 2){ // true transition in automaton
987 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
988 xbt_dynar_push(successors, &next_pair);
996 xbt_dynar_foreach(successors, cursor, pair_succ){
998 if(search_cycle == 1){
1000 if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){
1002 if(reached(pair_succ->automaton_state)){
1003 //if(reached_hash(pair_succ->automaton_state)){
1005 XBT_DEBUG("Next pair (depth = %d, %u interleave) already reached !", xbt_fifo_size(mc_stack_liveness) + 1, MC_state_interleave_size(pair_succ->graph_state));
1007 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1008 XBT_INFO("| ACCEPTANCE CYCLE |");
1009 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1010 XBT_INFO("Counter-example that violates formula :");
1011 MC_show_stack_liveness(mc_stack_liveness);
1012 MC_dump_stack_liveness(mc_stack_liveness);
1013 MC_print_statistics_pairs(mc_stats_pair);
1018 XBT_DEBUG("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);
1020 set_pair_reached(pair_succ->automaton_state);
1021 //set_pair_reached_hash(pair_succ->automaton_state);
1023 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1024 //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1027 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1030 MC_ddfs(search_cycle);
1036 if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1037 //if(!visited(pair_succ->automaton_state, search_cycle)){
1040 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1043 MC_ddfs(search_cycle);
1047 XBT_DEBUG("Next pair already visited ! ");
1055 if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
1057 XBT_DEBUG("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);
1059 set_pair_reached(pair_succ->automaton_state);
1060 //set_pair_reached_hash(pair_succ->automaton_state);
1064 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1065 //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1069 if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1070 //if(!visited(pair_succ->automaton_state, search_cycle)){
1073 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1076 MC_ddfs(search_cycle);
1080 XBT_DEBUG("Next pair already visited ! ");
1087 /* Restore system before checking others successors */
1088 if(cursor != (xbt_dynar_length(successors) - 1))
1089 MC_replay_liveness(mc_stack_liveness, 1);
1094 if(MC_state_interleave_size(current_pair->graph_state) > 0){
1095 XBT_DEBUG("Backtracking to depth %d", xbt_fifo_size(mc_stack_liveness));
1096 MC_replay_liveness(mc_stack_liveness, 0);
1101 }else{ /*No request to execute, search evolution in Büchi automaton */
1105 /* Create the new expanded graph_state */
1106 next_graph_state = MC_state_pair_new();
1108 xbt_dynar_reset(successors);
1114 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
1116 res = MC_automaton_evaluate_label(transition_succ->label);
1118 if(res == 1){ // enabled transition in automaton
1120 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
1121 xbt_dynar_push(successors, &next_pair);
1129 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
1131 res = MC_automaton_evaluate_label(transition_succ->label);
1133 if(res == 2){ // true transition in automaton
1135 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
1136 xbt_dynar_push(successors, &next_pair);
1144 xbt_dynar_foreach(successors, cursor, pair_succ){
1146 if(search_cycle == 1){
1148 if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){
1150 if(reached(pair_succ->automaton_state)){
1151 //if(reached_hash(pair_succ->automaton_state)){
1153 XBT_DEBUG("Next pair (depth = %d) already reached !", xbt_fifo_size(mc_stack_liveness) + 1);
1155 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1156 XBT_INFO("| ACCEPTANCE CYCLE |");
1157 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1158 XBT_INFO("Counter-example that violates formula :");
1159 MC_show_stack_liveness(mc_stack_liveness);
1160 MC_dump_stack_liveness(mc_stack_liveness);
1161 MC_print_statistics_pairs(mc_stats_pair);
1166 XBT_DEBUG("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);
1168 set_pair_reached(pair_succ->automaton_state);
1169 //set_pair_reached_hash(pair_succ->automaton_state);
1171 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1172 //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1175 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1178 MC_ddfs(search_cycle);
1184 if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1185 //if(!visited(pair_succ->automaton_state, search_cycle)){
1188 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1191 MC_ddfs(search_cycle);
1195 XBT_DEBUG("Next pair already visited ! ");
1203 if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
1205 set_pair_reached(pair_succ->automaton_state);
1206 //set_pair_reached_hash(pair_succ->automaton_state);
1210 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1211 //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1215 if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1216 //if(!visited(pair_succ->automaton_state, search_cycle)){
1219 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1222 MC_ddfs(search_cycle);
1226 XBT_DEBUG("Next pair already visited ! ");
1232 /* Restore system before checking others successors */
1233 if(cursor != xbt_dynar_length(successors) - 1)
1234 MC_replay_liveness(mc_stack_liveness, 1);
1243 XBT_DEBUG("Max depth reached");
1247 if(xbt_fifo_size(mc_stack_liveness) == MAX_DEPTH_LIVENESS ){
1248 XBT_DEBUG("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) );
1250 XBT_DEBUG("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) );
1255 xbt_fifo_shift(mc_stack_liveness);
1256 if((current_pair->automaton_state->type == 1) || (current_pair->automaton_state->type == 2)){
1257 xbt_dynar_pop(reached_pairs, NULL);
1258 //xbt_dynar_pop(reached_pairs_hash, NULL);