Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[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/api/ActorState.hpp"
11 #include "src/mc/remote/CheckerSide.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 algorithms to control the execution of
21  *  the application process during the exploration of the execution graph.
22  *
23  *  One day, this will allow parallel exploration, ie, the handling of several application processes (each encapsulated
24  * in a separate CheckerSide objects) that explore several parts of the exploration graph.
25  */
26 class XBT_PUBLIC RemoteApp {
27 private:
28   std::unique_ptr<CheckerSide> checker_side_;
29   std::unique_ptr<CheckerSide> application_factory_; // when no meminfo, create checker_side_ by cloning this one
30   int master_socket_ = -1;
31
32   const std::vector<char*> app_args_;
33
34   // No copy:
35   RemoteApp(RemoteApp const&) = delete;
36   RemoteApp& operator=(RemoteApp const&) = delete;
37
38 public:
39   /** Create a new session by executing the provided code in a fork()
40    *
41    *  This sets up the environment for the model-checked process
42    *  (environment variables, sockets, etc.).
43    *
44    *  The code is expected to `exec` the model-checked application.
45    */
46   explicit RemoteApp(const std::vector<char*>& args);
47
48   void restore_initial_state();
49   void wait_for_requests();
50
51   /** Ask to the application to check for a deadlock. If so, do an error message and throw a McError(DEADLOCK). */
52   void check_deadlock() const;
53
54   /** Ask the application to run post-mortem analysis, and maybe to stop ASAP */
55   void finalize_app(bool terminate_asap = false);
56
57   /** Retrieve the max PID of the running actors */
58   unsigned long get_maxpid() const;
59
60   /* Get the list of actors that are ready to run at that step. Usually shorter than maxpid */
61   void get_actors_status(std::map<aid_t, simgrid::mc::ActorState>& whereto) const;
62
63   /** Take a transition. A new Transition is created iff the last parameter is true */
64   Transition* handle_simcall(aid_t aid, int times_considered, bool new_transition);
65 };
66 } // namespace simgrid::mc
67
68 #endif