4 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_liveness, mc,
5 "Logging specific to algorithms for liveness properties verification");
7 xbt_dynar_t initial_pairs = NULL;
9 xbt_dynar_t reached_pairs;
10 extern mc_snapshot_t initial_snapshot;
12 mc_pair_t new_pair(mc_snapshot_t sn, mc_state_t sg, xbt_state_t st){
14 p = xbt_new0(s_mc_pair_t, 1);
16 p->automaton_state = st;
20 mc_stats_pair->expanded_pairs++;
25 int reached(mc_pair_t pair){
27 char* hash_reached = malloc(sizeof(char)*160);
31 char *hash = malloc(sizeof(char)*160);
32 xbt_sha((char *)&pair, hash);
33 xbt_dynar_foreach(reached_pairs, c, hash_reached){
34 if(strcmp(hash, hash_reached) == 0){
44 void set_pair_reached(mc_pair_t pair){
46 if(reached(pair) == 0){
48 char *hash = malloc(sizeof(char)*160) ;
49 xbt_sha((char *)&pair, hash);
50 xbt_dynar_push(reached_pairs, &hash);
56 void MC_pair_delete(mc_pair_t pair){
57 xbt_free(pair->graph_state->proc_status);
58 xbt_free(pair->graph_state);
59 //xbt_free(pair->automaton_state); -> FIXME : à implémenter
64 int MC_automaton_evaluate_label(xbt_automaton_t a, xbt_exp_label_t l){
68 int left_res = MC_automaton_evaluate_label(a, l->u.or_and.left_exp);
69 int right_res = MC_automaton_evaluate_label(a, l->u.or_and.right_exp);
70 return (left_res || right_res);
74 int left_res = MC_automaton_evaluate_label(a, l->u.or_and.left_exp);
75 int right_res = MC_automaton_evaluate_label(a, l->u.or_and.right_exp);
76 return (left_res && right_res);
80 int res = MC_automaton_evaluate_label(a, l->u.exp_not);
85 unsigned int cursor = 0;
86 xbt_propositional_symbol_t p = NULL;
87 xbt_dynar_foreach(a->propositional_symbols, cursor, p){
88 if(strcmp(p->pred, l->u.predicat) == 0){
89 int (*f)() = p->function;
107 /******************************* DFS with visited state *******************************/
109 xbt_dynar_t visited_pairs;
111 void set_pair_visited(mc_pair_t pair, int sc){
114 mc_visited_pair_t p = NULL;
115 p = xbt_new0(s_mc_visited_pair_t, 1);
117 p->search_cycle = sc;
118 char *hash = malloc(sizeof(char)*160);
119 xbt_sha((char *)&p, hash);
120 xbt_dynar_push(visited_pairs, &hash);
125 int visited(mc_pair_t pair, int sc){
127 char* hash_visited = malloc(sizeof(char)*160);
131 mc_visited_pair_t p = NULL;
132 p = xbt_new0(s_mc_visited_pair_t, 1);
134 p->search_cycle = sc;
135 char *hash = malloc(sizeof(char)*160);
136 xbt_sha((char *)&p, hash);
137 xbt_dynar_foreach(visited_pairs, c, hash_visited){
138 if(strcmp(hash, hash_visited) == 0){
150 void MC_vddfs_stateful_init(xbt_automaton_t a){
152 XBT_DEBUG("**************************************************");
153 XBT_DEBUG("Double-DFS stateful with visited state init");
154 XBT_DEBUG("**************************************************");
156 mc_pair_t mc_initial_pair;
157 mc_state_t initial_graph_state;
158 smx_process_t process;
159 mc_snapshot_t init_snapshot;
161 MC_wait_for_requests();
165 init_snapshot = xbt_new0(s_mc_snapshot_t, 1);
167 initial_graph_state = MC_state_pair_new();
168 xbt_swag_foreach(process, simix_global->process_list){
169 if(MC_process_is_enabled(process)){
170 MC_state_interleave_process(initial_graph_state, process);
174 visited_pairs = xbt_dynar_new(sizeof(char *), NULL);
175 reached_pairs = xbt_dynar_new(sizeof(char *), NULL);
177 MC_take_snapshot(init_snapshot);
181 unsigned int cursor = 0;
182 xbt_state_t state = NULL;
184 xbt_dynar_foreach(a->states, cursor, state){
185 if(state->type == -1){
188 mc_initial_pair = new_pair(init_snapshot, initial_graph_state, state);
189 xbt_fifo_unshift(mc_stack_liveness_stateful, mc_initial_pair);
193 MC_vddfs_stateful(a, 0, 0);
195 MC_restore_snapshot(init_snapshot);
197 MC_vddfs_stateful(a, 0, 0);
200 if(state->type == 2){
203 mc_initial_pair = new_pair(init_snapshot, initial_graph_state, state);
204 xbt_fifo_unshift(mc_stack_liveness_stateful, mc_initial_pair);
208 MC_vddfs_stateful(a, 1, 0);
210 MC_restore_snapshot(init_snapshot);
212 MC_vddfs_stateful(a, 1, 0);
220 void MC_vddfs_stateful(xbt_automaton_t a, int search_cycle, int restore){
222 smx_process_t process = NULL;
225 if(xbt_fifo_size(mc_stack_liveness_stateful) == 0)
229 MC_restore_snapshot(((mc_pair_t)xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack_liveness_stateful)))->system_state);
234 /* Get current state */
235 mc_pair_t current_pair = (mc_pair_t)xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack_liveness_stateful));
238 xbt_swag_foreach(process, simix_global->process_list){
239 if(MC_process_is_enabled(process)){
240 MC_state_interleave_process(current_pair->graph_state, process);
245 XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d )", xbt_fifo_size(mc_stack_liveness_stateful), search_cycle);
246 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));
249 mc_stats_pair->visited_pairs++;
252 mc_state_t next_graph_state = NULL;
253 smx_req_t req = NULL;
257 xbt_transition_t transition_succ;
261 xbt_dynar_t successors = xbt_dynar_new(sizeof(mc_pair_t), NULL);
264 mc_snapshot_t next_snapshot;
265 mc_snapshot_t current_snapshot;
268 while((req = MC_state_get_request(current_pair->graph_state, &value)) != NULL){
271 current_snapshot = xbt_new0(s_mc_snapshot_t, 1);
272 MC_take_snapshot(current_snapshot);
276 /* Debug information */
277 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
278 req_str = MC_request_to_string(req, value);
279 XBT_DEBUG("Execute: %s", req_str);
283 MC_state_set_executed_request(current_pair->graph_state, req, value);
285 /* Answer the request */
286 SIMIX_request_pre(req, value);
288 /* Wait for requests (schedules processes) */
289 MC_wait_for_requests();
292 /* Create the new expanded graph_state */
295 next_graph_state = MC_state_pair_new();
297 /* Get enabled process and insert it in the interleave set of the next graph_state */
298 xbt_swag_foreach(process, simix_global->process_list){
299 if(MC_process_is_enabled(process)){
300 MC_state_interleave_process(next_graph_state, process);
304 next_snapshot = xbt_new0(s_mc_snapshot_t, 1);
305 MC_take_snapshot(next_snapshot);
309 xbt_dynar_reset(successors);
312 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
314 res = MC_automaton_evaluate_label(a, transition_succ->label);
319 next_pair = new_pair(next_snapshot,next_graph_state, transition_succ->dst);
320 xbt_dynar_push(successors, &next_pair);
327 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
329 res = MC_automaton_evaluate_label(a, transition_succ->label);
334 next_pair = new_pair(next_snapshot,next_graph_state, transition_succ->dst);
335 xbt_dynar_push(successors, &next_pair);
343 if(xbt_dynar_length(successors) == 0){
346 next_pair = new_pair(next_snapshot, next_graph_state, current_pair->automaton_state);
347 xbt_dynar_push(successors, &next_pair);
353 //XBT_DEBUG("Successors length %lu", xbt_dynar_length(successors));
356 xbt_dynar_foreach(successors, cursor, pair_succ){
358 //XBT_DEBUG("Search visited pair : graph=%p, automaton=%p", pair_succ->graph_state, pair_succ->automaton_state);
360 if((search_cycle == 1) && (reached(pair_succ) == 1)){
361 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
362 XBT_INFO("| ACCEPTANCE CYCLE |");
363 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
364 XBT_INFO("Counter-example that violates formula :");
365 MC_show_stack_liveness_stateful(mc_stack_liveness_stateful);
366 MC_dump_stack_liveness_stateful(mc_stack_liveness_stateful);
367 MC_print_statistics_pairs(mc_stats_pair);
371 if(visited(pair_succ, search_cycle) == 0){
373 mc_stats_pair->executed_transitions++;
376 xbt_fifo_unshift(mc_stack_liveness_stateful, pair_succ);
377 set_pair_visited(pair_succ, search_cycle);
378 //XBT_DEBUG("New pair (graph=%p, automaton=%p) in stack", pair_succ->graph_state, pair_succ->automaton_state);
381 MC_vddfs_stateful(a, search_cycle, 0);
383 //XBT_DEBUG("Pair (graph=%p, automaton=%p) expanded", pair_succ->graph_state, pair_succ->automaton_state);
385 if((search_cycle == 0) && ((current_pair->automaton_state->type == 1) || (current_pair->automaton_state->type == 2))){
387 MC_restore_snapshot(current_pair->system_state);
390 xbt_swag_foreach(process, simix_global->process_list){
391 if(MC_process_is_enabled(process)){
392 MC_state_interleave_process(current_pair->graph_state, process);
397 set_pair_reached(current_pair);
398 XBT_DEBUG("Acceptance pair : graph=%p, automaton=%p(%s)", current_pair->graph_state, current_pair->automaton_state, current_pair->automaton_state->id);
399 MC_vddfs_stateful(a, 1, 1);
400 xbt_dynar_pop(reached_pairs, NULL);
406 XBT_DEBUG("Pair already visited !");
411 if(MC_state_interleave_size(current_pair->graph_state) > 0){
412 MC_restore_snapshot(current_snapshot);
420 xbt_fifo_shift(mc_stack_liveness_stateful);
421 XBT_DEBUG("Pair (graph=%p, automaton =%p) shifted in stack", current_pair->graph_state, current_pair->automaton_state);
430 /********************* Double-DFS stateful without visited state *******************/
433 void MC_ddfs_stateful_init(xbt_automaton_t a){
435 XBT_DEBUG("**************************************************");
436 XBT_DEBUG("Double-DFS stateful without visited state init");
437 XBT_DEBUG("**************************************************");
439 mc_pair_t mc_initial_pair;
440 mc_state_t initial_graph_state;
441 smx_process_t process;
442 mc_snapshot_t init_snapshot;
444 MC_wait_for_requests();
448 init_snapshot = xbt_new0(s_mc_snapshot_t, 1);
450 initial_graph_state = MC_state_pair_new();
451 xbt_swag_foreach(process, simix_global->process_list){
452 if(MC_process_is_enabled(process)){
453 MC_state_interleave_process(initial_graph_state, process);
457 reached_pairs = xbt_dynar_new(sizeof(char *), NULL);
459 MC_take_snapshot(init_snapshot);
463 unsigned int cursor = 0;
464 xbt_state_t state = NULL;
466 xbt_dynar_foreach(a->states, cursor, state){
467 if(state->type == -1){
470 mc_initial_pair = new_pair(init_snapshot, initial_graph_state, state);
471 xbt_fifo_unshift(mc_stack_liveness_stateful, mc_initial_pair);
475 MC_ddfs_stateful(a, 0, 0);
477 MC_restore_snapshot(init_snapshot);
479 MC_ddfs_stateful(a, 0, 0);
482 if(state->type == 2){
485 mc_initial_pair = new_pair(init_snapshot, initial_graph_state, state);
486 xbt_fifo_unshift(mc_stack_liveness_stateful, mc_initial_pair);
490 MC_ddfs_stateful(a, 1, 0);
492 MC_restore_snapshot(init_snapshot);
494 MC_ddfs_stateful(a, 1, 0);
502 void MC_ddfs_stateful(xbt_automaton_t a, int search_cycle, int restore){
504 smx_process_t process = NULL;
507 if(xbt_fifo_size(mc_stack_liveness_stateful) == 0)
511 MC_restore_snapshot(((mc_pair_t)xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack_liveness_stateful)))->system_state);
516 /* Get current state */
517 mc_pair_t current_pair = (mc_pair_t)xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack_liveness_stateful));
520 xbt_swag_foreach(process, simix_global->process_list){
521 if(MC_process_is_enabled(process)){
522 MC_state_interleave_process(current_pair->graph_state, process);
527 XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d )", xbt_fifo_size(mc_stack_liveness_stateful), search_cycle);
528 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));
530 mc_stats_pair->visited_pairs++;
533 mc_state_t next_graph_state = NULL;
534 smx_req_t req = NULL;
538 xbt_transition_t transition_succ;
542 xbt_dynar_t successors = xbt_dynar_new(sizeof(mc_pair_t), NULL);
545 mc_snapshot_t next_snapshot;
546 mc_snapshot_t current_snapshot;
551 while((req = MC_state_get_request(current_pair->graph_state, &value)) != NULL){
554 current_snapshot = xbt_new0(s_mc_snapshot_t, 1);
555 MC_take_snapshot(current_snapshot);
559 /* Debug information */
560 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
561 req_str = MC_request_to_string(req, value);
562 XBT_DEBUG("%u Execute: %s", search_cycle, req_str);
566 MC_state_set_executed_request(current_pair->graph_state, req, value);
568 /* Answer the request */
569 SIMIX_request_pre(req, value);
571 /* Wait for requests (schedules processes) */
572 MC_wait_for_requests();
575 /* Create the new expanded graph_state */
578 next_graph_state = MC_state_pair_new();
580 /* Get enabled process and insert it in the interleave set of the next graph_state */
581 xbt_swag_foreach(process, simix_global->process_list){
582 if(MC_process_is_enabled(process)){
583 MC_state_interleave_process(next_graph_state, process);
587 next_snapshot = xbt_new0(s_mc_snapshot_t, 1);
588 MC_take_snapshot(next_snapshot);
592 xbt_dynar_reset(successors);
595 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
597 res = MC_automaton_evaluate_label(a, transition_succ->label);
601 if(res == 1){ // enabled transition in automaton
602 next_pair = new_pair(next_snapshot,next_graph_state, transition_succ->dst);
603 xbt_dynar_push(successors, &next_pair);
610 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
612 res = MC_automaton_evaluate_label(a, transition_succ->label);
616 if(res == 2){ // transition always enabled in automaton
617 next_pair = new_pair(next_snapshot,next_graph_state, transition_succ->dst);
618 xbt_dynar_push(successors, &next_pair);
625 if(xbt_dynar_length(successors) == 0){
628 next_pair = new_pair(next_snapshot, next_graph_state, current_pair->automaton_state);
629 xbt_dynar_push(successors, &next_pair);
634 //XBT_DEBUG("Successors in automaton %lu", xbt_dynar_length(successors));
637 xbt_dynar_foreach(successors, cursor, pair_succ){
639 //XBT_DEBUG("Search visited pair : graph=%p, automaton=%p", pair_succ->graph_state, pair_succ->automaton_state);
641 if((search_cycle == 1) && (reached(pair_succ) == 1)){
642 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
643 XBT_INFO("| ACCEPTANCE CYCLE |");
644 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
645 XBT_INFO("Counter-example that violates formula :");
646 MC_show_stack_liveness_stateful(mc_stack_liveness_stateful);
647 MC_dump_stack_liveness_stateful(mc_stack_liveness_stateful);
648 MC_print_statistics_pairs(mc_stats_pair);
652 //mc_stats_pair->executed_transitions++;
655 xbt_fifo_unshift(mc_stack_liveness_stateful, pair_succ);
658 MC_ddfs_stateful(a, search_cycle, 0);
661 if((search_cycle == 0) && ((current_pair->automaton_state->type == 1) || (current_pair->automaton_state->type == 2))){
663 MC_restore_snapshot(current_pair->system_state);
666 xbt_swag_foreach(process, simix_global->process_list){
667 if(MC_process_is_enabled(process)){
668 MC_state_interleave_process(current_pair->graph_state, process);
672 set_pair_reached(current_pair);
673 XBT_DEBUG("Acceptance pair : graph=%p, automaton=%p(%s)", current_pair->graph_state, current_pair->automaton_state, current_pair->automaton_state->id);
674 MC_ddfs_stateful(a, 1, 1);
676 xbt_dynar_pop(reached_pairs, NULL);
680 if(MC_state_interleave_size(current_pair->graph_state) > 0){
681 MC_restore_snapshot(current_snapshot);
689 xbt_fifo_shift(mc_stack_liveness_stateful);
690 XBT_DEBUG("Pair (graph=%p, automaton =%p) shifted in stack", current_pair->graph_state, current_pair->automaton_state);
697 /********************* Double-DFS stateless *******************/
699 void MC_pair_stateless_delete(mc_pair_stateless_t pair){
700 xbt_free(pair->graph_state->proc_status);
701 xbt_free(pair->graph_state);
702 //xbt_free(pair->automaton_state); -> FIXME : à implémenter
706 mc_pair_stateless_t new_pair_stateless(mc_state_t sg, xbt_state_t st){
707 mc_pair_stateless_t p = NULL;
708 p = xbt_new0(s_mc_pair_stateless_t, 1);
709 p->automaton_state = st;
711 mc_stats_pair->expanded_pairs++;
716 int reached_stateless(mc_pair_stateless_t pair){
718 char* hash_reached = malloc(sizeof(char)*160);
722 char *hash = malloc(sizeof(char)*160);
723 xbt_sha((char *)&pair, hash);
724 xbt_dynar_foreach(reached_pairs, c, hash_reached){
725 if(strcmp(hash, hash_reached) == 0){
735 void set_pair_stateless_reached(mc_pair_stateless_t pair){
737 if(reached_stateless(pair) == 0){
740 char *hash = malloc(sizeof(char)*160) ;
741 xbt_sha((char *)&pair, hash);
742 xbt_dynar_push(reached_pairs, &hash);
749 void MC_ddfs_stateless_init(xbt_automaton_t a){
751 XBT_DEBUG("**************************************************");
752 XBT_DEBUG("Double-DFS stateless init");
753 XBT_DEBUG("**************************************************");
755 mc_pair_stateless_t mc_initial_pair;
756 mc_state_t initial_graph_state;
757 smx_process_t process;
759 MC_wait_for_requests();
763 initial_graph_state = MC_state_pair_new();
764 xbt_swag_foreach(process, simix_global->process_list){
765 if(MC_process_is_enabled(process)){
766 MC_state_interleave_process(initial_graph_state, process);
770 reached_pairs = xbt_dynar_new(sizeof(char *), NULL);
774 /* regarder dans l'automate toutes les transitions activables grâce à l'état initial du système
775 -> donnera les états initiaux de la propriété consistants avec l'état initial du système */
777 unsigned int cursor = 0;
778 //unsigned int cursor2 = 0;
779 xbt_state_t state = NULL;
781 //xbt_transition_t transition_succ;
782 //xbt_dynar_t successors = xbt_dynar_new(sizeof(mc_pair_stateless_t), NULL);
783 //xbt_dynar_t elses = xbt_dynar_new(sizeof(mc_pair_stateless_t), NULL);
784 //mc_pair_stateless_t pair_succ;
786 /*xbt_dynar_foreach(a->states, cursor, state){
787 if(state->type == -1){
788 xbt_dynar_foreach(state->out, cursor2, transition_succ){
789 res = MC_automaton_evaluate_label(a, transition_succ->label);
795 mc_initial_pair = new_pair_stateless(initial_graph_state, transition_succ->dst);
796 xbt_dynar_push(successors, &mc_initial_pair);
808 xbt_dynar_foreach(a->states, cursor, state){
809 if(state->type == -1){
810 xbt_dynar_foreach(state->out, cursor2, transition_succ){
811 res = MC_automaton_evaluate_label(a, transition_succ->label);
817 mc_initial_pair = new_pair_stateless(initial_graph_state, transition_succ->dst);
818 xbt_dynar_push(successors, &mc_initial_pair);
830 if((xbt_dynar_length(successors) == 0) && (xbt_dynar_length(elses) == 0)){
831 xbt_dynar_foreach(a->states, cursor, state){
832 if(state->type == -1){
835 mc_initial_pair = new_pair_stateless(initial_graph_state, transition_succ->dst);
836 xbt_dynar_push(successors, &mc_initial_pair);
845 xbt_dynar_foreach(successors, cursor, pair_succ){
848 xbt_fifo_unshift(mc_stack_liveness_stateless, pair_succ);
850 initial_snapshot = xbt_new0(s_mc_snapshot_t, 1);
851 MC_take_snapshot(initial_snapshot);
856 MC_ddfs_stateless(a, 0, 0);
858 MC_ddfs_stateless(a, 0, 1);
862 xbt_dynar_foreach(a->states, cursor, state){
863 if(state->type == -1){
866 mc_initial_pair = new_pair_stateless(initial_graph_state, state);
867 xbt_fifo_unshift(mc_stack_liveness_stateless, mc_initial_pair);
869 initial_snapshot = xbt_new0(s_mc_snapshot_t, 1);
870 MC_take_snapshot(initial_snapshot);
875 MC_ddfs_stateless(a, 0, 0);
877 MC_restore_snapshot(initial_snapshot);
879 MC_ddfs_stateless(a, 0, 0);
882 if(state->type == 2){
885 mc_initial_pair = new_pair_stateless(initial_graph_state, state);
886 xbt_fifo_unshift(mc_stack_liveness_stateless, mc_initial_pair);
888 initial_snapshot = xbt_new0(s_mc_snapshot_t, 1);
889 MC_take_snapshot(initial_snapshot);
894 MC_ddfs_stateless(a, 1, 0);
896 MC_restore_snapshot(initial_snapshot);
898 MC_ddfs_stateless(a, 1, 0);
907 void MC_ddfs_stateless(xbt_automaton_t a, int search_cycle, int replay){
909 smx_process_t process = NULL;
911 if(xbt_fifo_size(mc_stack_liveness_stateless) == 0)
915 MC_replay_liveness(mc_stack_liveness_stateless);
918 //XBT_DEBUG("Stack size before restore %u", xbt_fifo_size(mc_stack_liveness_stateless));
920 /* Get current state */
921 mc_pair_stateless_t current_pair = (mc_pair_stateless_t)xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack_liveness_stateless));
923 XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d )", xbt_fifo_size(mc_stack_liveness_stateless), search_cycle);
924 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));
926 mc_stats_pair->visited_pairs++;
929 mc_state_t next_graph_state = NULL;
930 smx_req_t req = NULL;
933 mc_pair_stateless_t pair_succ;
934 xbt_transition_t transition_succ;
938 xbt_dynar_t successors;
940 mc_pair_stateless_t next_pair;
941 //mc_snapshot_t current_snap;
944 while((req = MC_state_get_request(current_pair->graph_state, &value)) != NULL){
946 //XBT_DEBUG("Interleave size %u", MC_state_interleave_size(current_pair->graph_state));
948 /* Debug information */
949 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
950 req_str = MC_request_to_string(req, value);
951 XBT_DEBUG("Execute: %s", req_str);
957 MC_state_set_executed_request(current_pair->graph_state, req, value);
959 /* Answer the request */
960 SIMIX_request_pre(req, value);
962 /* Wait for requests (schedules processes) */
963 MC_wait_for_requests();
966 /* Create the new expanded graph_state */
969 next_graph_state = MC_state_pair_new();
971 /* Get enabled process and insert it in the interleave set of the next graph_state */
972 xbt_swag_foreach(process, simix_global->process_list){
973 if(MC_process_is_enabled(process)){
974 MC_state_interleave_process(next_graph_state, process);
978 successors = xbt_dynar_new(sizeof(mc_pair_stateless_t), NULL);
982 //xbt_dynar_reset(successors);
986 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
988 res = MC_automaton_evaluate_label(a, transition_succ->label);
992 if(res == 1){ // enabled transition in automaton
993 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst);
994 xbt_dynar_push(successors, &next_pair);
1002 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
1004 res = MC_automaton_evaluate_label(a, transition_succ->label);
1008 if(res == 2){ // enabled transition in automaton
1009 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst);
1010 xbt_dynar_push(successors, &next_pair);
1017 if(xbt_dynar_length(successors) == 0){
1020 next_pair = new_pair_stateless(next_graph_state, current_pair->automaton_state);
1021 xbt_dynar_push(successors, &next_pair);
1027 //XBT_DEBUG("Successors length %lu", xbt_dynar_length(successors));
1029 xbt_dynar_foreach(successors, cursor, pair_succ){
1031 if((search_cycle == 1) && (reached_stateless(pair_succ) == 1)){
1032 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1033 XBT_INFO("| ACCEPTANCE CYCLE |");
1034 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1035 XBT_INFO("Counter-example that violates formula :");
1036 MC_show_stack_liveness_stateless(mc_stack_liveness_stateless);
1037 MC_dump_stack_liveness_stateless(mc_stack_liveness_stateless);
1038 MC_print_statistics_pairs(mc_stats_pair);
1042 mc_stats_pair->executed_transitions++;
1045 xbt_fifo_unshift(mc_stack_liveness_stateless, pair_succ);
1048 MC_ddfs_stateless(a, search_cycle, 0);
1050 //XBT_DEBUG("Stack size %u", xbt_fifo_size(mc_stack_liveness_stateless));
1052 if((search_cycle == 0) && ((current_pair->automaton_state->type == 1) || (current_pair->automaton_state->type == 2))){
1054 /*xbt_swag_foreach(process, simix_global->process_list){
1055 if(MC_process_is_enabled(process)){
1056 MC_state_interleave_process(current_pair->graph_state, process);
1060 set_pair_stateless_reached(current_pair);
1061 XBT_DEBUG("Acceptance pair : graph=%p, automaton=%p(%s)", current_pair->graph_state, current_pair->automaton_state, current_pair->automaton_state->id);
1063 MC_ddfs_stateless(a, 1, 1);
1065 xbt_dynar_pop(reached_pairs, NULL);
1069 if(MC_state_interleave_size(current_pair->graph_state) > 0){
1070 XBT_DEBUG("Backtracking to depth %u", xbt_fifo_size(mc_stack_liveness_stateless));
1071 MC_replay_liveness(mc_stack_liveness_stateless);
1078 xbt_fifo_shift(mc_stack_liveness_stateless);
1079 XBT_DEBUG("Pair (graph=%p, automaton =%p, search_cycle = %u) shifted in stack", current_pair->graph_state, current_pair->automaton_state, search_cycle);