Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'maximal-subset-search' into 'master'
[simgrid.git] / src / mc / api / RemoteApp.hpp
1 /* Copyright (c) 2016-2023. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SIMGRID_MC_REMOTE_APP_HPP
7 #define SIMGRID_MC_REMOTE_APP_HPP
8
9 #include "simgrid/forward.h"
10 #include "src/mc/ModelChecker.hpp"
11 #include "src/mc/api/ActorState.hpp"
12 #include "src/mc/remote/RemotePtr.hpp"
13
14 #include <functional>
15
16 namespace simgrid::mc {
17
18 /** High-level view of the verified application, from the model-checker POV
19  *
20  *  This is expected to become the interface used by model-checking
21  *  algorithms to control the execution of the model-checked process
22  *  and the exploration of the execution graph. Model-checking
23  *  algorithms should be able to be written in high-level languages
24  *  (e.g. Python) using bindings on this interface.
25  */
26 class XBT_PUBLIC RemoteApp {
27 private:
28   std::unique_ptr<ModelChecker> model_checker_;
29   PageStore page_store_{500};
30   std::shared_ptr<simgrid::mc::Snapshot> initial_snapshot_;
31
32   // No copy:
33   RemoteApp(RemoteApp const&) = delete;
34   RemoteApp& operator=(RemoteApp const&) = delete;
35
36 public:
37   /** Create a new session by executing the provided code in a fork()
38    *
39    *  This sets up the environment for the model-checked process
40    *  (environment variables, sockets, etc.).
41    *
42    *  The code is expected to `exec` the model-checked application.
43    */
44   explicit RemoteApp(const std::vector<char*>& args);
45
46   ~RemoteApp();
47
48   void restore_initial_state() const;
49
50   /** Ask to the application to check for a deadlock. If so, do an error message and throw a DeadlockError. */
51   void check_deadlock() const;
52
53   /** Retrieve the max PID of the running actors */
54   unsigned long get_maxpid() const;
55
56   /* Get the list of actors that are ready to run at that step. Usually shorter than maxpid */
57   void get_actors_status(std::map<aid_t, simgrid::mc::ActorState>& whereto) const;
58
59   /* Get the remote process */
60   RemoteProcess& get_remote_process() { return model_checker_->get_remote_process(); }
61
62   PageStore& get_page_store() { return page_store_; }
63 };
64 } // namespace simgrid::mc
65
66 #endif