Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
new dfs algorithm with automaton of LTL formula
[simgrid.git] / src / mc / private.h
index a1720fd..6bfc90a 100644 (file)
@@ -18,6 +18,7 @@
 #include "xbt/function_types.h"
 #include "xbt/mmalloc.h"
 #include "../simix/private.h"
+#include "xbt/automaton.h"
 
 /****************************** Snapshots ***********************************/
 
@@ -37,6 +38,7 @@ void MC_restore_snapshot(mc_snapshot_t);
 void MC_free_snapshot(mc_snapshot_t);
 
 /********************************* MC Global **********************************/
+extern double *mc_time;
 
 /* Bound of the MC depth-first search algorithm */
 #define MAX_DEPTH 1000
@@ -51,7 +53,13 @@ void MC_dump_stack(xbt_fifo_t stack);
 
 /********************************* Requests ***********************************/
 int MC_request_depend(smx_req_t req1, smx_req_t req2);
-char* MC_request_to_string(smx_req_t req);
+char* MC_request_to_string(smx_req_t req, int value);
+unsigned int MC_request_testany_fail(smx_req_t req);
+/*int MC_waitany_is_enabled_by_comm(smx_req_t req, unsigned int comm);*/
+int MC_request_is_visible(smx_req_t req);
+int MC_request_is_enabled(smx_req_t req);
+int MC_request_is_enabled_by_idx(smx_req_t req, unsigned int idx);
+int MC_process_is_enabled(smx_process_t process);
 
 /********************************** DPOR **************************************/
 void MC_dpor_init(void);
@@ -61,7 +69,7 @@ void MC_dpor_exit(void);
 /******************************** States **************************************/
 /* Possible exploration status of a process in a state */
 typedef enum {
-  MC_NOT_INTERLEAVE = 0,    /* Do not interleave (do not execute) */
+  MC_NOT_INTERLEAVE=0,      /* Do not interleave (do not execute) */
   MC_INTERLEAVE,            /* Interleave the process (one or more request) */
   MC_DONE                   /* Already interleaved */
 } e_mc_process_state_t;
@@ -69,30 +77,32 @@ typedef enum {
 /* On every state, each process has an entry of the following type */
 typedef struct mc_procstate{
   e_mc_process_state_t state;       /* Exploration control information */
-  unsigned int num_to_interleave;   /* Number of request to interleave */
-  /* If a process has a request with multiple possible responses like a */
-  /* "WaitAny", then the following vector with the indexes to interleave */
-  /* is additionally used. */
-  unsigned int *requests_indexes;   /* Indexes of the requests to interleave */
+  unsigned int interleave_count;    /* Number of times that the process was
+                                       interleaved */
 } s_mc_procstate_t, *mc_procstate_t;
 
 /* An exploration state is composed of: */
 typedef struct mc_state {
   unsigned long max_pid;            /* Maximum pid at state's creation time */
   mc_procstate_t proc_status;       /* State's exploration status by process */
-  s_smx_req_t executed;             /* The executed request of the state */
+  s_smx_action_t internal_comm;     /* To be referenced by the internal_req */
+  s_smx_req_t internal_req;         /* Internal translation of request */
+  s_smx_req_t executed_req;         /* The executed request of the state */
+  int req_num;                      /* The request number (in the case of a
+                                       multi-request like waitany ) */
 } s_mc_state_t, *mc_state_t;
 
 extern xbt_fifo_t mc_stack;
 
 mc_state_t MC_state_new(void);
 void MC_state_delete(mc_state_t state);
-void MC_state_add_to_interleave(mc_state_t state, smx_process_t process);
+void MC_state_interleave_process(mc_state_t state, smx_process_t process);
 unsigned int MC_state_interleave_size(mc_state_t state);
 int MC_state_process_is_done(mc_state_t state, smx_process_t process);
-void MC_state_set_executed_request(mc_state_t state, smx_req_t req);
-smx_req_t MC_state_get_executed_request(mc_state_t state);
-smx_req_t MC_state_get_request(mc_state_t state, char *value);
+void MC_state_set_executed_request(mc_state_t state, smx_req_t req, int value);
+smx_req_t MC_state_get_executed_request(mc_state_t state, int *value);
+smx_req_t MC_state_get_internal_request(mc_state_t state);
+smx_req_t MC_state_get_request(mc_state_t state, int *value);
 
 /****************************** Statistics ************************************/
 typedef struct mc_stats {
@@ -113,7 +123,7 @@ void MC_print_statistics(mc_stats_t);
 
 extern void *std_heap;
 extern void *raw_heap;
-int raw_heap_fd;
+/* extern int raw_heap_fd; */ /* unused */
 #define STD_HEAP_SIZE   20480000        /* Maximum size of the system's heap */
 
 /* FIXME: Horrible hack! because the mmalloc library doesn't provide yet of */
@@ -159,5 +169,22 @@ typedef struct s_memory_map {
 
 memory_map_t get_memory_map(void);
 
+/********************************** DFS **************************************/
+
+typedef struct s_mc_pairs{
+  mc_snapshot_t system_state;
+  mc_state_t graph_state;
+  xbt_state_t automaton_state;
+  int visited;
+  int num;
+}s_mc_pairs_t, *mc_pairs_t;
+
+void MC_dfs_init(xbt_automaton_t a);
+void MC_dfs(xbt_automaton_t automaton, int search_cycle);
+int MC_automaton_evaluate_label(xbt_automaton_t a, xbt_exp_label_t l);
+mc_pairs_t new_pair(mc_snapshot_t sn, mc_state_t sg, xbt_state_t st);
+void set_pair_visited(mc_pairs_t p);
+int pair_reached(xbt_dynar_t p, int num_pair);
+
 
 #endif