Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
e62c1f68c51ced2dc469d1f2fad284d3347e856d
[simgrid.git] / src / mc / mc_liveness.c
1 /* Copyright (c) 2011-2013. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "mc_private.h"
8 #include <unistd.h>
9 #include <sys/wait.h>
10
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_liveness, mc,
12                                 "Logging specific to algorithms for liveness properties verification");
13
14 /********* Global variables *********/
15
16 xbt_dynar_t acceptance_pairs;
17 xbt_dynar_t visited_pairs;
18 xbt_dynar_t successors;
19 xbt_parmap_t parmap;
20
21 /********* Static functions *********/
22
23 static xbt_dynar_t get_atomic_propositions_values(){
24   int res;
25   int_f_void_t f;
26   unsigned int cursor = 0;
27   xbt_automaton_propositional_symbol_t ps = NULL;
28   xbt_dynar_t values = xbt_dynar_new(sizeof(int), NULL);
29
30   xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps){
31     f = (int_f_void_t)ps->function;
32     res = f();
33     xbt_dynar_push_as(values, int, res);
34   }
35
36   return values;
37 }
38
39 static int get_search_interval(xbt_dynar_t all_pairs, mc_pair_t pair, int *min, int *max){
40
41   int raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
42
43   MC_SET_RAW_MEM;
44
45   int cursor = 0, previous_cursor, next_cursor;
46   mc_pair_t pair_test;
47   int start = 0;
48   int end = xbt_dynar_length(all_pairs) - 1;
49   
50   while(start <= end){
51     cursor = (start + end) / 2;
52     pair_test = (mc_pair_t)xbt_dynar_get_as(all_pairs, cursor, mc_pair_t);
53     if(pair_test->nb_processes < pair->nb_processes){
54       start = cursor + 1;
55     }else if(pair_test->nb_processes > pair->nb_processes){
56       end = cursor - 1;
57     }else{
58       if(pair_test->heap_bytes_used < pair->heap_bytes_used){
59         start = cursor +1;
60       }else if(pair_test->heap_bytes_used > pair->heap_bytes_used){
61         end = cursor - 1;
62       }else{
63         *min = *max = cursor;
64         previous_cursor = cursor - 1;
65         while(previous_cursor >= 0){
66           pair_test = (mc_pair_t)xbt_dynar_get_as(all_pairs, previous_cursor, mc_pair_t);
67           if(pair_test->nb_processes != pair->nb_processes || pair_test->heap_bytes_used != pair->heap_bytes_used)
68             break;
69           *min = previous_cursor;
70           previous_cursor--;
71         }
72         next_cursor = cursor + 1;
73         while(next_cursor < xbt_dynar_length(all_pairs)){
74           pair_test = (mc_pair_t)xbt_dynar_get_as(all_pairs, next_cursor, mc_pair_t);
75           if(pair_test->nb_processes != pair->nb_processes || pair_test->heap_bytes_used != pair->heap_bytes_used)
76             break;
77           *max = next_cursor;
78           next_cursor++;
79         }
80         if(!raw_mem_set)
81           MC_UNSET_RAW_MEM;
82         return -1;
83       }
84      }
85   }
86
87   if(!raw_mem_set)
88     MC_UNSET_RAW_MEM;
89
90   return cursor;
91 }
92
93 static int is_reached_acceptance_pair(mc_pair_t pair){
94
95   int raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
96
97   MC_SET_RAW_MEM;
98  
99   if(xbt_dynar_is_empty(acceptance_pairs)){
100
101     if(pair->graph_state->system_state == NULL){
102       pair->graph_state->system_state = MC_take_snapshot();
103       pair->heap_bytes_used = mmalloc_get_bytes_used(std_heap);
104     }
105     xbt_dynar_push(acceptance_pairs, &pair); 
106
107     if(!raw_mem_set)
108       MC_UNSET_RAW_MEM;
109
110     return -1;
111
112   }else{
113
114     if(pair->graph_state->system_state == NULL){
115       pair->graph_state->system_state = MC_take_snapshot();
116       pair->heap_bytes_used = mmalloc_get_bytes_used(std_heap);
117     }
118
119     int min = -1, max = -1, index;
120     int res;
121     mc_pair_t pair_test;
122     
123     index = get_search_interval(acceptance_pairs, pair, &min, &max);
124
125     if(min != -1 && max != -1){ /* Acceptance pair with same number of processes and same heap bytes used exists */
126       res = xbt_parmap_mc_apply(parmap, snapshot_compare, xbt_dynar_get_ptr(acceptance_pairs, min), (max-min)+1, pair);
127       if(res != -1){
128         if(!raw_mem_set)
129           MC_UNSET_RAW_MEM;
130         return ((mc_pair_t)xbt_dynar_get_as(acceptance_pairs, (min+res)-1, mc_pair_t))->num;
131       }
132       xbt_dynar_insert_at(acceptance_pairs, min, &pair);
133     }else{
134       pair_test = (mc_pair_t)xbt_dynar_get_as(acceptance_pairs, index, mc_pair_t);
135       if(pair_test->nb_processes < pair->nb_processes){
136         xbt_dynar_insert_at(acceptance_pairs, index+1, &pair);
137       }else{
138         if(pair_test->heap_bytes_used < pair->heap_bytes_used)
139           xbt_dynar_insert_at(acceptance_pairs, index + 1, &pair);
140         else
141           xbt_dynar_insert_at(acceptance_pairs, index, &pair);
142       }
143     }
144
145     if(!raw_mem_set)
146       MC_UNSET_RAW_MEM;
147     
148     return -1;
149     
150   }
151  
152 }
153
154
155 static void set_acceptance_pair_reached(mc_pair_t pair){
156
157   int raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
158
159   MC_SET_RAW_MEM;
160
161   if(xbt_dynar_is_empty(acceptance_pairs)){
162
163      if(pair->graph_state->system_state == NULL){
164        pair->graph_state->system_state = MC_take_snapshot();
165        pair->heap_bytes_used = mmalloc_get_bytes_used(std_heap);
166      }
167      xbt_dynar_push(acceptance_pairs, &pair); 
168
169   }else{
170
171     if(pair->graph_state->system_state == NULL){
172       pair->graph_state->system_state = MC_take_snapshot();
173       pair->heap_bytes_used = mmalloc_get_bytes_used(std_heap);
174     }
175     
176     size_t current_bytes_used = pair->heap_bytes_used;
177     int current_nb_processes = pair->nb_processes;
178
179     int cursor = 0;
180     int start = 0;
181     int end = xbt_dynar_length(acceptance_pairs) - 1;
182
183     mc_pair_t pair_test = NULL;
184     size_t bytes_used_test = 0;
185     int nb_processes_test;
186
187     while(start <= end){
188       cursor = (start + end) / 2;
189       pair_test = (mc_pair_t)xbt_dynar_get_as(acceptance_pairs, cursor, mc_pair_t);
190       bytes_used_test = pair_test->heap_bytes_used;
191       nb_processes_test = pair_test->nb_processes;
192       if(nb_processes_test < current_nb_processes)
193         start = cursor + 1;
194       if(nb_processes_test > current_nb_processes)
195         end = cursor - 1; 
196       if(nb_processes_test == current_nb_processes){
197         if(bytes_used_test < current_bytes_used)
198           start = cursor + 1;
199         if(bytes_used_test > current_bytes_used)
200           end = cursor - 1;
201         if(bytes_used_test == current_bytes_used)
202           break;
203       }
204     }
205
206     if(pair_test->nb_processes < pair->nb_processes){
207       xbt_dynar_insert_at(acceptance_pairs, cursor+1, &pair);
208     }else{
209       if(pair_test->heap_bytes_used < pair->heap_bytes_used)
210         xbt_dynar_insert_at(acceptance_pairs, cursor + 1, &pair);
211       else
212         xbt_dynar_insert_at(acceptance_pairs, cursor, &pair);
213     }    
214
215   }
216
217   if(!raw_mem_set)
218     MC_UNSET_RAW_MEM;
219     
220 }
221
222 static void remove_acceptance_pair(mc_pair_t pair){
223
224   int raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
225
226   MC_SET_RAW_MEM;
227
228   unsigned int cursor = 0;
229   mc_pair_t pair_test;
230   int pair_found = 0;
231
232   xbt_dynar_foreach(acceptance_pairs, cursor, pair_test){
233     if(pair_test->num == pair->num){
234       pair_found = 1;
235       break;
236     }
237   }
238
239   if(pair_found)
240     xbt_dynar_remove_at(acceptance_pairs, cursor, NULL);
241   
242   pair->acceptance_removed = 1;
243
244   if(pair->stack_removed && pair->acceptance_removed){
245     if(_sg_mc_visited == 0){
246       MC_pair_delete(pair);
247     }else if(pair->visited_removed){
248       MC_pair_delete(pair);
249     }
250   }
251
252   if(!raw_mem_set)
253     MC_UNSET_RAW_MEM;
254 }
255
256 static int is_visited_pair(mc_pair_t pair){
257
258   if(_sg_mc_visited == 0)
259     return -1;
260
261   int raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
262
263   MC_SET_RAW_MEM;
264
265   if(xbt_dynar_is_empty(visited_pairs)){
266
267     if(pair->graph_state->system_state == NULL)
268       pair->graph_state->system_state = MC_take_snapshot();
269     xbt_dynar_push(visited_pairs, &pair); 
270
271     if(!raw_mem_set)
272       MC_UNSET_RAW_MEM;
273
274     return -1;
275
276   }else{
277
278     if(pair->graph_state->system_state == NULL)
279       pair->graph_state->system_state = MC_take_snapshot();
280
281     int min = -1, max = -1, index;
282     int res;
283     mc_pair_t pair_test;
284
285     index = get_search_interval(visited_pairs, pair, &min, &max);
286
287     if(min != -1 && max != -1){ /* Visited pair with same number of processes and same heap bytes used exists */
288       res = xbt_parmap_mc_apply(parmap, snapshot_compare, xbt_dynar_get_ptr(visited_pairs, min), (max-min)+1, pair);
289       if(res != -1){
290         pair_test = (mc_pair_t)xbt_dynar_get_as(visited_pairs, (min+res)-1, mc_pair_t);
291         if(pair_test->other_num == -1)
292           pair->other_num = pair_test->num;
293         else
294           pair->other_num = pair_test->other_num;
295         if(dot_output == NULL)
296           XBT_DEBUG("Pair %d already visited ! (equal to pair %d)", pair->num, pair_test->num);
297         else
298           XBT_DEBUG("Pair %d already visited ! (equal to pair %d (pair %d in dot_output))", pair->num, pair_test->num, pair->other_num);
299         xbt_dynar_remove_at(visited_pairs, (min + res) - 1, NULL);
300         xbt_dynar_insert_at(visited_pairs, (min+res) - 1, &pair);
301         pair_test->visited_removed = 1;
302         if(pair_test->stack_removed && pair_test->visited_removed){
303           if((pair_test->automaton_state->type == 1) || (pair_test->automaton_state->type == 2)){
304             if(pair_test->acceptance_removed){
305               MC_pair_delete(pair_test);
306             }
307           }else{
308             MC_pair_delete(pair_test);
309           }
310         }
311         if(!raw_mem_set)
312           MC_UNSET_RAW_MEM;
313         return pair->other_num;
314       }
315       xbt_dynar_insert_at(visited_pairs, min, &pair);
316     }else{
317       pair_test = (mc_pair_t)xbt_dynar_get_as(visited_pairs, index, mc_pair_t);
318       if(pair_test->nb_processes < pair->nb_processes){
319         xbt_dynar_insert_at(visited_pairs, index+1, &pair);
320       }else{
321         if(pair_test->heap_bytes_used < pair->heap_bytes_used)
322           xbt_dynar_insert_at(visited_pairs, index + 1, &pair);
323         else
324           xbt_dynar_insert_at(visited_pairs, index, &pair);
325       }
326     }
327
328     if(xbt_dynar_length(visited_pairs) > _sg_mc_visited){
329       int min2 = mc_stats->expanded_pairs;
330       unsigned int cursor2 = 0;
331       unsigned int index2 = 0;
332       xbt_dynar_foreach(visited_pairs, cursor2, pair_test){
333         if(pair_test->num < min2){
334           index2 = cursor2;
335           min2 = pair_test->num;
336         }
337       }
338       xbt_dynar_remove_at(visited_pairs, index2, &pair_test);
339       pair_test->visited_removed = 1;
340       if(pair_test->stack_removed && pair_test->acceptance_removed && pair_test->visited_removed)
341         MC_pair_delete(pair_test);
342       
343     }
344
345     if(!raw_mem_set)
346       MC_UNSET_RAW_MEM;
347     
348     return -1;
349
350   }
351 }
352
353 static int MC_automaton_evaluate_label(xbt_automaton_exp_label_t l, xbt_dynar_t atomic_propositions_values){
354   
355   switch(l->type){
356   case 0 : {
357     int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp, atomic_propositions_values);
358     int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp, atomic_propositions_values);
359     return (left_res || right_res);
360   }
361   case 1 : {
362     int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp, atomic_propositions_values);
363     int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp, atomic_propositions_values);
364     return (left_res && right_res);
365   }
366   case 2 : {
367     int res = MC_automaton_evaluate_label(l->u.exp_not, atomic_propositions_values);
368     return (!res);
369   }
370   case 3 : { 
371     unsigned int cursor = 0;
372     xbt_automaton_propositional_symbol_t p = NULL;
373     xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, p){
374       if(strcmp(p->pred, l->u.predicat) == 0)
375         return (int)xbt_dynar_get_as(atomic_propositions_values, cursor, int);
376     }
377     return -1;
378   }
379   case 4 : {
380     return 2;
381   }
382   default : 
383     return -1;
384   }
385 }
386
387
388 /********* DDFS Algorithm *********/
389
390
391 void MC_ddfs_init(void){
392
393   initial_state_liveness->raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
394
395   XBT_DEBUG("**************************************************");
396   XBT_DEBUG("Double-DFS init");
397   XBT_DEBUG("**************************************************");
398
399   mc_pair_t initial_pair = NULL;
400   smx_process_t process; 
401
402   MC_wait_for_requests();
403
404   MC_SET_RAW_MEM;
405
406   acceptance_pairs = xbt_dynar_new(sizeof(mc_pair_t), NULL); 
407   visited_pairs = xbt_dynar_new(sizeof(mc_pair_t), NULL); 
408   successors = xbt_dynar_new(sizeof(mc_pair_t), NULL);
409
410   initial_state_liveness->snapshot = MC_take_snapshot();
411   initial_state_liveness->prev_pair = 0;
412
413   MC_UNSET_RAW_MEM; 
414   
415   unsigned int cursor = 0;
416   xbt_automaton_state_t automaton_state;
417
418   xbt_dynar_foreach(_mc_property_automaton->states, cursor, automaton_state){
419     if(automaton_state->type == -1){ /* Initial automaton state */
420       
421       MC_SET_RAW_MEM;
422
423       initial_pair = MC_pair_new();
424       initial_pair->automaton_state = automaton_state;
425       initial_pair->graph_state = MC_state_new();
426       initial_pair->atomic_propositions = get_atomic_propositions_values();
427
428       /* Get enabled process and insert it in the interleave set of the graph_state */
429       xbt_swag_foreach(process, simix_global->process_list){
430         if(MC_process_is_enabled(process)){
431           MC_state_interleave_process(initial_pair->graph_state, process);
432         }
433       }
434
435       initial_pair->requests = MC_state_interleave_size(initial_pair->graph_state);
436       initial_pair->search_cycle = 0;
437
438       xbt_fifo_unshift(mc_stack_liveness, initial_pair);
439
440       MC_UNSET_RAW_MEM;
441       
442       MC_ddfs();
443       
444       if(cursor != 0){
445         MC_restore_snapshot(initial_state_liveness->snapshot);
446         MC_UNSET_RAW_MEM;
447       }
448       
449
450     }else if(automaton_state->type == 2){ /* Acceptance automaton state */
451       
452       MC_SET_RAW_MEM;
453
454       initial_pair = MC_pair_new();
455       initial_pair->automaton_state = automaton_state;
456       initial_pair->graph_state = MC_state_new();
457       initial_pair->atomic_propositions = get_atomic_propositions_values();
458         
459       /* Get enabled process and insert it in the interleave set of the graph_state */
460       xbt_swag_foreach(process, simix_global->process_list){
461         if(MC_process_is_enabled(process)){
462           MC_state_interleave_process(initial_pair->graph_state, process);
463         }
464       }
465
466       initial_pair->requests = MC_state_interleave_size(initial_pair->graph_state);
467       initial_pair->search_cycle = 1;
468         
469       xbt_fifo_unshift(mc_stack_liveness, initial_pair);
470         
471       MC_UNSET_RAW_MEM;
472
473       set_acceptance_pair_reached(initial_pair);
474   
475       MC_ddfs();
476
477       if(cursor != 0){
478         MC_restore_snapshot(initial_state_liveness->snapshot);
479         MC_UNSET_RAW_MEM;
480       }
481     }
482   }
483
484   if(initial_state_liveness->raw_mem_set)
485     MC_SET_RAW_MEM;
486   else
487     MC_UNSET_RAW_MEM;
488   
489
490 }
491
492
493 void MC_ddfs(){
494
495   smx_process_t process;
496   mc_pair_t current_pair = NULL;
497
498   if(xbt_fifo_size(mc_stack_liveness) == 0)
499     return;
500
501   /* Get current pair */
502   current_pair = (mc_pair_t)xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack_liveness));
503
504   /* Update current state in buchi automaton */
505   _mc_property_automaton->current_state = current_pair->automaton_state;
506
507   XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d, interleave size %d)", xbt_fifo_size(mc_stack_liveness), current_pair->search_cycle, MC_state_interleave_size(current_pair->graph_state));
508  
509   mc_stats->visited_pairs++;
510
511   int value;
512   smx_simcall_t req = NULL;
513   char *req_str;
514
515   xbt_automaton_transition_t transition_succ;
516   unsigned int cursor = 0;
517   int res;
518   int reached_num, visited_num;
519
520   mc_pair_t next_pair = NULL;
521   xbt_dynar_t prop_values = NULL;
522   
523   if(xbt_fifo_size(mc_stack_liveness) < _sg_mc_max_depth){
524
525     if(current_pair->requests > 0){
526
527       if(current_pair->search_cycle){
528
529         if((current_pair->automaton_state->type == 1) || (current_pair->automaton_state->type == 2)){ 
530           
531           if((reached_num = is_reached_acceptance_pair(current_pair)) != -1){
532         
533             XBT_INFO("Pair %d already reached (equal to pair %d) !", current_pair->num, reached_num);
534             
535             MC_SET_RAW_MEM;
536             xbt_fifo_shift(mc_stack_liveness);
537             if(dot_output != NULL)
538               fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", initial_state_liveness->prev_pair, reached_num, initial_state_liveness->prev_req);
539             MC_UNSET_RAW_MEM;
540
541             XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
542             XBT_INFO("|             ACCEPTANCE CYCLE            |");
543             XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
544             XBT_INFO("Counter-example that violates formula :");
545             MC_show_stack_liveness(mc_stack_liveness);
546             MC_dump_stack_liveness(mc_stack_liveness);
547             MC_print_statistics(mc_stats);
548             xbt_abort();
549
550           }
551         }
552       }
553
554       if((visited_num = is_visited_pair(current_pair)) != -1){
555
556         MC_SET_RAW_MEM;
557         if(dot_output != NULL)
558           fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", initial_state_liveness->prev_pair, visited_num, initial_state_liveness->prev_req);
559         MC_UNSET_RAW_MEM;
560         
561       
562       }else{  
563
564         while((req = MC_state_get_request(current_pair->graph_state, &value)) != NULL){
565
566           MC_SET_RAW_MEM;
567           if(dot_output != NULL){
568             if(initial_state_liveness->prev_pair != 0 && initial_state_liveness->prev_pair != current_pair->num){
569               fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", initial_state_liveness->prev_pair, current_pair->num, initial_state_liveness->prev_req);
570               xbt_free(initial_state_liveness->prev_req);
571             }
572             initial_state_liveness->prev_pair = current_pair->num;
573           }
574           MC_UNSET_RAW_MEM;
575
576           /* Debug information */
577           if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
578             req_str = MC_request_to_string(req, value);
579             XBT_DEBUG("Execute: %s", req_str);
580             xbt_free(req_str);
581           }
582
583           MC_SET_RAW_MEM;
584           if(dot_output != NULL){
585             initial_state_liveness->prev_req = MC_request_get_dot_output(req, value);
586             if(current_pair->search_cycle)
587               fprintf(dot_output, "%d [shape=doublecircle];\n", current_pair->num);
588           }
589           MC_UNSET_RAW_MEM; 
590           
591           MC_state_set_executed_request(current_pair->graph_state, req, value);  
592           mc_stats->executed_transitions++;
593
594           /* Answer the request */
595           SIMIX_simcall_pre(req, value);
596           
597           /* Wait for requests (schedules processes) */
598           MC_wait_for_requests();
599
600           MC_SET_RAW_MEM;
601           prop_values = get_atomic_propositions_values();
602           MC_UNSET_RAW_MEM;
603          
604           /* Evaluate enabled transition according to atomic propositions values */
605           cursor= 0;
606           xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
607
608             res = MC_automaton_evaluate_label(transition_succ->label, prop_values);
609
610             if(res == 1){ // enabled transition in automaton
611
612               MC_SET_RAW_MEM;
613
614               next_pair = MC_pair_new();
615               next_pair->graph_state = MC_state_new();
616               next_pair->automaton_state = transition_succ->dst;
617               next_pair->atomic_propositions = get_atomic_propositions_values();
618
619               /* Get enabled process and insert it in the interleave set of the next graph_state */
620               xbt_swag_foreach(process, simix_global->process_list){
621                 if(MC_process_is_enabled(process)){
622                   MC_state_interleave_process(next_pair->graph_state, process);
623                 }
624               }
625
626               next_pair->requests = MC_state_interleave_size(next_pair->graph_state);
627               
628               if(next_pair->automaton_state->type == 1 || next_pair->automaton_state->type == 2 || current_pair->search_cycle)
629                 next_pair->search_cycle = 1;
630             
631               xbt_fifo_unshift(mc_stack_liveness, next_pair);
632
633               if(mc_stats->expanded_pairs%1000000 == 0)
634                 XBT_INFO("Expanded pairs : %lu", mc_stats->expanded_pairs);
635
636               MC_UNSET_RAW_MEM;
637
638               MC_ddfs();
639
640             }
641
642           }
643
644           /* Then, evaluate true transitions (always true, whatever atomic propositions values) */
645           cursor = 0;   
646           xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
647       
648             res = MC_automaton_evaluate_label(transition_succ->label, prop_values);
649   
650             if(res == 2){ // true transition in automaton
651             
652               MC_SET_RAW_MEM;
653             
654               next_pair = MC_pair_new();
655               next_pair->graph_state = MC_state_new();
656               next_pair->automaton_state = transition_succ->dst;
657               next_pair->atomic_propositions = get_atomic_propositions_values();
658
659               /* Get enabled process and insert it in the interleave set of the next graph_state */
660               xbt_swag_foreach(process, simix_global->process_list){
661                 if(MC_process_is_enabled(process)){
662                   MC_state_interleave_process(next_pair->graph_state, process);
663                 }
664               }
665
666               next_pair->requests = MC_state_interleave_size(next_pair->graph_state);
667             
668               if(next_pair->automaton_state->type == 1 || next_pair->automaton_state->type == 2 || current_pair->search_cycle)
669                 next_pair->search_cycle = 1;
670
671               xbt_fifo_unshift(mc_stack_liveness, next_pair);
672
673               if(mc_stats->expanded_pairs%1000000 == 0)
674                 XBT_INFO("Expanded pairs : %lu", mc_stats->expanded_pairs);
675             
676               MC_UNSET_RAW_MEM;
677
678               MC_ddfs();
679
680             }
681
682           }
683
684           if(MC_state_interleave_size(current_pair->graph_state) > 0){
685             XBT_DEBUG("Backtracking to depth %d", xbt_fifo_size(mc_stack_liveness));
686             MC_replay_liveness(mc_stack_liveness, 0);
687           }
688         
689         }
690
691       }
692  
693     }else{
694
695       mc_stats->executed_transitions++;
696       
697       XBT_DEBUG("No request to execute in this state, search evolution in Büchi Automaton.");
698
699       if(current_pair->search_cycle){
700
701         if((current_pair->automaton_state->type == 1) || (current_pair->automaton_state->type == 2)){ 
702           
703           if((reached_num = is_reached_acceptance_pair(current_pair)) != -1){
704         
705             XBT_INFO("Pair %d already reached (equal to pair %d) !", current_pair->num, reached_num);
706             
707             MC_SET_RAW_MEM;
708             xbt_fifo_shift(mc_stack_liveness);
709             MC_UNSET_RAW_MEM;
710
711             XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
712             XBT_INFO("|             ACCEPTANCE CYCLE            |");
713             XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
714             XBT_INFO("Counter-example that violates formula :");
715             MC_show_stack_liveness(mc_stack_liveness);
716             MC_dump_stack_liveness(mc_stack_liveness);
717             MC_print_statistics(mc_stats);
718             xbt_abort();
719
720           }
721         }
722       }
723
724       if((visited_num = is_visited_pair(current_pair)) != -1){
725
726         XBT_DEBUG("Pair %d already visited ! (equal to pair %d)", current_pair->num, visited_num);
727       
728       }else{            
729         
730         MC_SET_RAW_MEM;
731         prop_values = get_atomic_propositions_values();
732         MC_UNSET_RAW_MEM;
733
734         /* Evaluate enabled transition according to atomic propositions values */
735         cursor= 0;
736         xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
737
738           res = MC_automaton_evaluate_label(transition_succ->label, prop_values);
739
740           if(res == 1){ // enabled transition in automaton
741
742             MC_SET_RAW_MEM;
743
744             next_pair = MC_pair_new();
745             next_pair->graph_state = MC_state_new();
746             next_pair->automaton_state = transition_succ->dst;
747             next_pair->atomic_propositions = get_atomic_propositions_values();
748             next_pair->requests = MC_state_interleave_size(next_pair->graph_state);
749               
750             if(next_pair->automaton_state->type == 1 || next_pair->automaton_state->type == 2 || current_pair->search_cycle)
751               next_pair->search_cycle = 1;
752             
753             xbt_fifo_unshift(mc_stack_liveness, next_pair);
754
755             if(mc_stats->expanded_pairs%1000 == 0)
756               XBT_INFO("Expanded pairs : %lu", mc_stats->expanded_pairs);
757
758             if(dot_output != NULL)
759               fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", current_pair->num, next_pair->num, "");
760
761             MC_UNSET_RAW_MEM;
762
763             MC_ddfs();
764
765           }
766
767         }
768
769         /* Then, evaluate true transitions (always true, whatever atomic propositions values) */
770         cursor = 0;   
771         xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
772       
773           res = MC_automaton_evaluate_label(transition_succ->label, prop_values);
774   
775           if(res == 2){ // true transition in automaton
776
777             MC_SET_RAW_MEM;
778             
779             next_pair = MC_pair_new();
780             next_pair->graph_state = MC_state_new();
781             next_pair->automaton_state = transition_succ->dst;
782             next_pair->atomic_propositions = get_atomic_propositions_values();
783             next_pair->requests = MC_state_interleave_size(next_pair->graph_state);
784             
785             if(next_pair->automaton_state->type == 1 || next_pair->automaton_state->type == 2 || current_pair->search_cycle)
786               next_pair->search_cycle = 1;
787
788             xbt_fifo_unshift(mc_stack_liveness, next_pair);
789
790             if(mc_stats->expanded_pairs%1000 == 0)
791               XBT_INFO("Expanded pairs : %lu", mc_stats->expanded_pairs);
792             
793             if(dot_output != NULL)
794               fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", current_pair->num, next_pair->num, "");
795
796             MC_UNSET_RAW_MEM;
797
798             MC_ddfs();
799
800           }
801
802         }
803       }
804     }
805     
806   }else{
807     
808     XBT_WARN("/!\\ Max depth reached ! /!\\ ");
809     if(MC_state_interleave_size(current_pair->graph_state) > 0){
810       XBT_WARN("/!\\ But, there are still processes to interleave. Model-checker will not be able to ensure the soundness of the verification from now. /!\\ "); 
811       if(_sg_mc_max_depth == 1000)
812         XBT_WARN("Notice : the default value of max depth is 1000 but you can change it with cfg=model-check/max_depth:value.");
813     }
814     
815   }
816
817   if(xbt_fifo_size(mc_stack_liveness) == _sg_mc_max_depth ){
818     XBT_DEBUG("Pair %d (depth = %d) shifted in stack, maximum depth reached", current_pair->num, xbt_fifo_size(mc_stack_liveness) );
819   }else{
820     XBT_DEBUG("Pair %d (depth = %d) shifted in stack", current_pair->num, xbt_fifo_size(mc_stack_liveness) );
821   }
822
823   
824   MC_SET_RAW_MEM;
825   xbt_dynar_free(&prop_values);
826   current_pair = xbt_fifo_shift(mc_stack_liveness);
827   current_pair->stack_removed = 1;
828   if(current_pair->search_cycle){
829     remove_acceptance_pair(current_pair);
830   }else{
831     if(_sg_mc_visited == 0)
832       MC_pair_delete(current_pair);
833     else if(current_pair->visited_removed)
834       MC_pair_delete(current_pair);
835   }
836
837   MC_UNSET_RAW_MEM;
838
839 }