Logo AND Algorithmique Numérique Distribuée

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