Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
7cf2315feb14baba5b7f391590844df410dfe645
[simgrid.git] / src / mc / mc_state.h
1 /* Copyright (c) 2007-2015. 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 #ifndef SIMGRID_MC_STATE_H
8 #define SIMGRID_MC_STATE_H
9
10 #include <xbt/base.h>
11
12 #include <simgrid_config.h>
13 #include "src/simix/smx_private.h"
14 #include "mc_snapshot.h"
15
16 SG_BEGIN_DECL()
17
18 extern XBT_PRIVATE mc_global_t initial_global_state;
19
20 /* Possible exploration status of a process in a state */
21 typedef enum {
22   MC_NOT_INTERLEAVE=0,      /* Do not interleave (do not execute) */
23   MC_INTERLEAVE,            /* Interleave the process (one or more request) */
24   MC_MORE_INTERLEAVE,       /* Interleave twice the process (for mc_random simcall) */
25   MC_DONE                   /* Already interleaved */
26 } e_mc_process_state_t;
27
28 /* On every state, each process has an entry of the following type */
29 typedef struct mc_procstate{
30   e_mc_process_state_t state;       /* Exploration control information */
31   unsigned int interleave_count;    /* Number of times that the process was
32                                        interleaved */
33 } s_mc_procstate_t, *mc_procstate_t;
34
35 /* An exploration state.
36  *
37  *  The `executed_state` is sometimes transformed into another `internal_req`.
38  *  For example WAITANY is transformes into a WAIT and TESTANY into TEST.
39  *  See `MC_state_set_executed_request()`.
40  */
41 typedef struct XBT_PRIVATE mc_state {
42   unsigned long max_pid;            /* Maximum pid at state's creation time */
43   mc_procstate_t proc_status;       /* State's exploration status by process */
44   s_smx_synchro_t internal_comm;     /* To be referenced by the internal_req */
45   s_smx_simcall_t internal_req;         /* Internal translation of request */
46   s_smx_simcall_t executed_req;         /* The executed request of the state */
47   int req_num;                      /* The request number (in the case of a
48                                        multi-request like waitany ) */
49   mc_snapshot_t system_state;      /* Snapshot of system state */
50   int num;
51   int in_visited_states;
52   // comm determinism verification (xbt_dynar_t<xbt_dynar_t<mc_comm_pattern_t>):
53   xbt_dynar_t incomplete_comm_pattern;
54   xbt_dynar_t index_comm; // comm determinism verification
55 } s_mc_state_t, *mc_state_t;
56
57 XBT_PRIVATE mc_state_t MC_state_new(void);
58 XBT_PRIVATE void MC_state_delete(mc_state_t state, int free_snapshot);
59 XBT_PRIVATE void MC_state_interleave_process(mc_state_t state, smx_process_t process);
60 XBT_PRIVATE unsigned int MC_state_interleave_size(mc_state_t state);
61 XBT_PRIVATE int MC_state_process_is_done(mc_state_t state, smx_process_t process);
62 XBT_PRIVATE void MC_state_set_executed_request(mc_state_t state, smx_simcall_t req, int value);
63 XBT_PRIVATE smx_simcall_t MC_state_get_executed_request(mc_state_t state, int *value);
64 XBT_PRIVATE smx_simcall_t MC_state_get_internal_request(mc_state_t state);
65 XBT_PRIVATE smx_simcall_t MC_state_get_request(mc_state_t state, int *value);
66 XBT_PRIVATE void MC_state_remove_interleave_process(mc_state_t state, smx_process_t process);
67
68 SG_END_DECL()
69
70 #endif