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. */
7 #ifndef SIMGRID_MC_SMX_H
8 #define SIMGRID_MC_SMX_H
13 #include <simgrid/simix.h>
15 #include "src/smpi/private.h"
17 #include "src/mc/Process.hpp"
18 #include "src/mc/mc_protocol.h"
21 * @brief (Cross-process, MCer/MCed) Access to SMX structures
23 * We copy some C data structure from the MCed process in the MCer process.
24 * This is implemented by:
26 * - `model_checker->process.smx_process_infos`
27 * (copy of `simix_global->process_list`);
29 * - `model_checker->process.smx_old_process_infos`
30 * (copy of `simix_global->process_to_destroy`);
32 * - `model_checker->hostnames`.
34 * The process lists are currently refreshed each time MCed code is executed.
35 * We don't try to give a persistent MCer address for a given MCed process.
36 * For this reason, a MCer simgrid::mc::Process* is currently not reusable after
42 struct s_mc_smx_process_info {
43 /** MCed address of the process */
45 /** (Flat) Copy of the process data structure */
46 struct s_smx_process copy;
47 /** Hostname (owned by `mc_modelchecker->hostnames`) */
52 typedef struct s_mc_smx_process_info s_mc_smx_process_info_t, *mc_smx_process_info_t;
54 XBT_PRIVATE xbt_dynar_t MC_smx_process_info_list_new(void);
56 XBT_PRIVATE void MC_process_smx_refresh(simgrid::mc::Process* process);
58 /** Get the issuer of a simcall (`req->issuer`)
60 * In split-process mode, it does the black magic necessary to get an address
61 * of a (shallow) copy of the data structure the issuer SIMIX process in the local
64 * @param process the MCed process
65 * @param req the simcall (copied in the local process)
67 XBT_PRIVATE smx_process_t MC_smx_simcall_get_issuer(smx_simcall_t req);
69 XBT_PRIVATE const char* MC_smx_process_get_name(smx_process_t p);
70 XBT_PRIVATE const char* MC_smx_process_get_host_name(smx_process_t p);
72 #define MC_EACH_SIMIX_PROCESS(process, code) \
73 if (mc_mode == MC_MODE_CLIENT) { \
74 xbt_swag_foreach(process, simix_global->process_list) { \
78 MC_process_smx_refresh(&mc_model_checker->process()); \
79 unsigned int _smx_process_index; \
80 mc_smx_process_info_t _smx_process_info; \
81 xbt_dynar_foreach_ptr(mc_model_checker->process().smx_process_infos, _smx_process_index, _smx_process_info) { \
82 smx_process_t process = &_smx_process_info->copy; \
87 /** Execute a given simcall */
88 XBT_PRIVATE void MC_simcall_handle(smx_simcall_t req, int value);
90 XBT_PRIVATE int MC_smpi_process_count(void);
93 /* ***** Resolve (local/MCer structure from remote/MCed addresses) ***** */
95 /** Get a local copy of the process from the process remote address */
96 XBT_PRIVATE smx_process_t MC_smx_resolve_process(smx_process_t process_remote_address);
98 /** Get the process info structure from the process remote address */
99 XBT_PRIVATE mc_smx_process_info_t MC_smx_resolve_process_info(smx_process_t process_remote_address);
101 XBT_PRIVATE unsigned long MC_smx_get_maxpid(void);