Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move the selection of the next transition to execute to mc::State
[simgrid.git] / src / mc / Transition.hpp
1 /* Copyright (c) 2015-2022. 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_TRANSITION_HPP
8 #define SIMGRID_MC_TRANSITION_HPP
9
10 #include "simgrid/forward.h" // aid_t
11 #include "src/mc/remote/RemotePtr.hpp"
12 #include <string>
13
14 namespace simgrid {
15 namespace mc {
16
17 /** An element in the recorded path
18  *
19  *  At each decision point, we need to record which process transition
20  *  is triggered and potentially which value is associated with this
21  *  transition. The value is used to find which communication is triggered
22  *  in things like waitany and for associating a given value of MC_random()
23  *  calls.
24  */
25 class Transition {
26   /* Textual representation of the transition, to display backtraces */
27   std::string textual_ = "";
28   static unsigned long executed_transitions_;
29
30 public:
31   aid_t aid_ = 0;
32
33   /* Which transition was executed for this simcall
34    *
35    * Some simcalls can lead to different transitions:
36    *
37    * * waitany/testany can trigger on different messages;
38    *
39    * * random can produce different values.
40    */
41   int times_considered_ = 0;
42
43   std::string to_string();
44
45   /* Explore a new path */
46   RemotePtr<simgrid::kernel::actor::SimcallObserver> execute(simgrid::mc::State* state, int next);
47   /* Moves the application toward a path that was already explored, but don't change the current transition */
48   RemotePtr<simgrid::kernel::actor::SimcallObserver> replay();
49
50   /* Returns the total amount of transitions executed so far (for statistics) */
51   static unsigned long get_executed_transitions() { return executed_transitions_; }
52 };
53
54 } // namespace mc
55 } // namespace simgrid
56
57 #endif