1 /* Copyright (c) 2007-2015. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #ifndef SIMGRID_MC_STATE_H
8 #define SIMGRID_MC_STATE_H
13 #include <xbt/dynar.h>
15 #include <simgrid_config.h>
16 #include "src/simix/smx_private.h"
17 #include "src/mc/mc_snapshot.h"
19 /* Possible exploration status of a process in a state */
21 MC_NOT_INTERLEAVE=0, /* Do not interleave (do not execute) */
22 MC_INTERLEAVE, /* Interleave the process (one or more request) */
23 MC_MORE_INTERLEAVE, /* Interleave twice the process (for mc_random simcall) */
24 MC_DONE /* Already interleaved */
25 } e_mc_process_state_t;
27 /* On every state, each process has an entry of the following type */
28 typedef struct mc_procstate{
29 e_mc_process_state_t state; /* Exploration control information */
30 unsigned int interleave_count; /* Number of times that the process was
32 } s_mc_procstate_t, *mc_procstate_t;
37 extern XBT_PRIVATE std::unique_ptr<s_mc_global_t> initial_global_state;
39 /* An exploration state.
41 * The `executed_state` is sometimes transformed into another `internal_req`.
42 * For example WAITANY is transformes into a WAIT and TESTANY into TEST.
43 * See `MC_state_set_executed_request()`.
45 struct XBT_PRIVATE State {
46 unsigned long max_pid = 0; /* Maximum pid at state's creation time */
47 mc_procstate_t proc_status = 0; /* State's exploration status by process */
48 s_smx_synchro_t internal_comm; /* To be referenced by the internal_req */
49 s_smx_simcall_t internal_req; /* Internal translation of request */
50 s_smx_simcall_t executed_req; /* The executed request of the state */
51 int req_num = 0; /* The request number (in the case of a
52 multi-request like waitany ) */
53 std::shared_ptr<simgrid::mc::Snapshot> system_state = nullptr; /* Snapshot of system state */
55 int in_visited_states = 0;
56 // comm determinism verification (xbt_dynar_t<xbt_dynar_t<mc_comm_pattern_t>):
57 xbt_dynar_t incomplete_comm_pattern = nullptr;
58 xbt_dynar_t index_comm = nullptr; // comm determinism verification
67 XBT_PRIVATE simgrid::mc::State* MC_state_new(void);
68 XBT_PRIVATE void MC_state_delete(simgrid::mc::State* state, int free_snapshot);
69 XBT_PRIVATE void MC_state_interleave_process(simgrid::mc::State* state, smx_process_t process);
70 XBT_PRIVATE unsigned int MC_state_interleave_size(simgrid::mc::State* state);
71 XBT_PRIVATE int MC_state_process_is_done(simgrid::mc::State* state, smx_process_t process);
72 XBT_PRIVATE void MC_state_set_executed_request(simgrid::mc::State* state, smx_simcall_t req, int value);
73 XBT_PRIVATE smx_simcall_t MC_state_get_executed_request(simgrid::mc::State* state, int *value);
74 XBT_PRIVATE smx_simcall_t MC_state_get_internal_request(simgrid::mc::State* state);
75 XBT_PRIVATE smx_simcall_t MC_state_get_request(simgrid::mc::State* state, int *value);
76 XBT_PRIVATE void MC_state_remove_interleave_process(simgrid::mc::State* state, smx_process_t process);