1 /* Copyright (c) 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. */
13 #include <simgrid/simix.h>
15 #include "mc_process.h"
16 #include "mc_protocol.h"
19 * @brief (Cross-process, MCer/MCed) Access to SMX structures
21 * We copy some C data structure from the MCed process in the MCer process.
22 * This is implemented by:
24 * - `model_checker->process.smx_process_infos`
25 * (copy of `simix_global->process_list`);
27 * - `model_checker->process.smx_old_process_infos`
28 * (copy of `simix_global->process_to_destroy`);
30 * - `model_checker->hostnames`.
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
40 struct s_mc_smx_process_info {
41 /** MCed address of the process */
43 /** (Flat) Copy of the process data structure */
44 struct s_smx_process copy;
45 /** Hostname (owned by `mc_modelchecker->hostnames`) */
50 xbt_dynar_t MC_smx_process_info_list_new(void);
52 void MC_process_smx_refresh(mc_process_t process);
54 /** Get the issuer of a simcall (`req->issuer`)
56 * In split-process mode, it does the black magic necessary to get an address
57 * of a (shallow) copy of the data structure the issuer SIMIX process in the local
60 * @param process the MCed process
61 * @param req the simcall (copied in the local process)
63 smx_process_t MC_smx_simcall_get_issuer(smx_simcall_t req);
65 const char* MC_smx_process_get_name(smx_process_t p);
66 const char* MC_smx_process_get_host_name(smx_process_t p);
68 #define MC_EACH_SIMIX_PROCESS(process, code) \
69 if (MC_process_is_self(&mc_model_checker->process)) { \
70 xbt_swag_foreach(process, simix_global->process_list) { \
74 MC_process_smx_refresh(&mc_model_checker->process); \
75 unsigned int _smx_process_index; \
76 mc_smx_process_info_t _smx_process_info; \
77 xbt_dynar_foreach_ptr(mc_model_checker->process.smx_process_infos, _smx_process_index, _smx_process_info) { \
78 smx_process_t process = &_smx_process_info->copy; \
83 /** Execute a given simcall */
84 void MC_simcall_handle(smx_simcall_t req, int value);
88 /* ***** Resolve (local/MCer structure from remote/MCed addresses) ***** */
90 /** Get a local copy of the process from the process remote address */
91 smx_process_t MC_smx_resolve_process(smx_process_t process_remote_address);
93 /** Get the process info structure from the process remote address */
94 mc_smx_process_info_t MC_smx_resolve_process_info(smx_process_t process_remote_address);