Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
0547bdb4cf404dd77c6c21b6578349b542104812
[simgrid.git] / src / mc / mc_state.c
1 #include "../simix/private.h"
2 #include "xbt/fifo.h"
3 #include "private.h"
4
5 static void MC_state_add_transition(mc_state_t state, mc_transition_t trans);
6
7 /**
8  * \brief Creates a state data structure used by the exploration algorithm
9  */
10 mc_state_t MC_state_new(void)
11 {
12   mc_state_t state = NULL;
13   
14   state = xbt_new0(s_mc_state_t, 1);
15   state->interleave = xbt_setset_new_set(mc_setset);
16   state->done = xbt_setset_new_set(mc_setset);
17   
18   mc_stats->expanded_states++;
19   return state;
20 }
21
22 /**
23  * \brief Deletes a state data structure
24  * \param trans The state to be deleted
25  */
26 void MC_state_delete(mc_state_t state)
27 {
28   xbt_setset_destroy_set(state->interleave);
29   xbt_setset_destroy_set(state->done);
30   xbt_free(state);
31 }
32
33 void MC_state_set_executed_request(mc_state_t state, smx_req_t req)
34 {
35   state->executed = *req;
36 }
37
38 smx_req_t MC_state_get_executed_request(mc_state_t state)
39 {
40   return &state->executed;
41 }
42
43 smx_req_t MC_state_get_request(mc_state_t state)
44 {
45   smx_process_t process = NULL;  
46   while((process = xbt_setset_set_extract(state->interleave))){
47     if(SIMIX_process_is_enabled(process)
48        && !xbt_setset_set_belongs(state->done, process)){
49       xbt_setset_set_insert(state->done, process);
50       return process->request;
51     }
52   }
53    
54   return NULL;
55 }