Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Read host name from remote process
[simgrid.git] / src / mc / mc_smx.h
1 /* Copyright (c) 2015. 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_SMX_H
8 #define MC_SMX_H
9
10 #include <stddef.h>
11
12 #include <xbt/log.h>
13 #include <simgrid/simix.h>
14
15 #include "mc_process.h"
16 #include "mc_protocol.h"
17
18 /** @file
19  *  @brief (Cross-process, MCer/MCed) Access to SMX structures
20  *
21  *  We copy some C data structure from the MCed process in the MCer process.
22  *  This is implemented by:
23  *
24  *   - `model_checker->process.smx_process_infos`
25  *      (copy of `simix_global->process_list`);
26  *
27  *   - `model_checker->process.smx_old_process_infos`
28  *      (copy of `simix_global->process_to_destroy`);
29  *
30  *   - `model_checker->hostnames`.
31  *
32  * The process lists are currently refreshed each time MCed code is executed.
33  * We don't try to give a persistent MCer address for a given MCed process.
34  * For this reason, a MCer mc_process_t is currently not reusable after
35  * MCed code.
36  */
37
38 SG_BEGIN_DECL()
39
40 struct s_mc_smx_process_info {
41   /** MCed address of the process */
42   void* address;
43   /** (Flat) Copy of the process data structure */
44   struct s_smx_process copy;
45   /** Hostname (owned by `mc_modelchecker->hostnames`) */
46   char* hostname;
47 };
48
49 xbt_dynar_t MC_smx_process_info_list_new(void);
50
51 void MC_process_smx_refresh(mc_process_t process);
52
53 /** Get the issuer of  a simcall (`req->issuer`)
54  *
55  *  In split-process mode, it does the black magic necessary to get an address
56  *  of a (shallow) copy of the data structure the issuer SIMIX process in the local
57  *  address space.
58  *
59  *  @param process the MCed process
60  *  @param req     the simcall (copied in the local process)
61  */
62 smx_process_t MC_smx_simcall_get_issuer(smx_simcall_t req);
63
64 const char* MC_smx_process_get_host_name(smx_process_t p);
65
66 #define MC_EACH_SIMIX_PROCESS(process, code) \
67   if (MC_process_is_self(&mc_model_checker->process)) { \
68     xbt_swag_foreach(process, simix_global->process_list) { \
69       code; \
70     } \
71   } else { \
72     MC_process_smx_refresh(&mc_model_checker->process); \
73     unsigned int _smx_process_index; \
74     mc_smx_process_info_t _smx_process_info; \
75     xbt_dynar_foreach_ptr(mc_model_checker->process.smx_process_infos, _smx_process_index, _smx_process_info) { \
76       smx_process_t process = &_smx_process_info->copy; \
77       code; \
78     } \
79   }
80
81 /** Execute a given simcall */
82 void MC_simcall_handle(smx_simcall_t req, int value);
83
84
85
86 /* ***** Resolve (local/MCer structure from remote/MCed addresses) ***** */
87
88 /** Get a local copy of the process from the process remote address */
89 smx_process_t MC_smx_resolve_process(smx_process_t process_remote_address);
90
91 /** Get the process info structure from the process remote address */
92 mc_smx_process_info_t MC_smx_resolve_process_info(smx_process_t process_remote_address);
93
94
95
96 SG_END_DECL()
97
98 #endif