structure, but always use the provided API to interact with
processes.
*/
-typedef struct s_smx_process *msg_process_t;
+typedef smx_process_t msg_process_t;
/** @brief Return code of most MSG functions
@ingroup msg_simulation
namespace simgrid {
namespace simix {
+
+ /** @brief Process datatype
+ @ingroup simix_process_management
+
+ A process may be defined as a <em>code</em>, with some <em>private
+ data</em>, executing in a <em>location</em>.
+ \see m_process_management
+ @{ */
+ class Process;
class Context;
class ContextFactory;
+
}
}
typedef simgrid::simix::Context *smx_context_t;
+typedef simgrid::simix::Process *smx_process_t;
#else
typedef struct s_smx_context *smx_context_t;
+typedef struct s_smx_process *smx_process_t;
#endif
typedef struct s_smx_storage_priv *smx_storage_priv_t;
/* ****************************** Process *********************************** */
-/** @brief Process datatype
- @ingroup simix_process_management
- A process may be defined as a <em>code</em>, with some <em>private
- data</em>, executing in a <em>location</em>.
- \see m_process_management
- @{ */
-typedef struct s_smx_process *smx_process_t;
typedef enum {
SMX_EXIT_SUCCESS = 0,
SMX_EXIT_FAILURE = 1
simgrid::mc::Client::initialize();
#endif
- s_smx_process_t proc;
-
if (!simix_global) {
simix_global = xbt_new0(s_smx_global_t, 1);
+ simgrid::simix::Process proc;
simix_global->process_to_run = xbt_dynar_new(sizeof(smx_process_t), NULL);
simix_global->process_that_ran = xbt_dynar_new(sizeof(smx_process_t), NULL);
simix_global->process_list = xbt_swag_new(xbt_swag_offset(proc, process_hookup));
void SIMIX_host_create(sg_host_t host) // FIXME: braindead prototype. Take sg_host as parameter
{
smx_host_priv_t smx_host = xbt_new0(s_smx_host_priv_t, 1);
- s_smx_process_t proc;
/* Host structure */
+ simgrid::simix::Process proc;
smx_host->process_list = xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
/* Update global variables */
xbt_dynar_free(&process->on_exit);
xbt_free(process->name);
- xbt_free(process);
+ delete process;
}
}
{
smx_process_t maestro = NULL;
/* Create maestro process and intilialize it */
- maestro = xbt_new0(s_smx_process_t, 1);
+ maestro = new simgrid::simix::Process();
maestro->pid = simix_process_maxpid++;
maestro->ppid = -1;
maestro->name = (char*) "";
xbt_free(argv);
}
else {
- process = xbt_new0(s_smx_process_t, 1);
+ process = new simgrid::simix::Process();
xbt_assert(((code != NULL) && (host != NULL)), "Invalid parameters");
/* Process data */
return nullptr;
}
- smx_process_t process = xbt_new0(s_smx_process_t, 1);
+ smx_process_t process = new simgrid::simix::Process();
/* Process data */
process->pid = simix_process_maxpid++;
process->name = xbt_strdup(name);
#include "simgrid/simix.h"
#include "popping_private.h"
-SG_BEGIN_DECL()
-
typedef struct s_smx_process_exit_fun {
int_f_pvoid_pvoid_t fun;
void *arg;
unsigned auto_restart:1;
} s_smx_process_arg_t, *smx_process_arg_t;
-/** @brief Process datatype */
-typedef struct s_smx_process {
- s_xbt_swag_hookup_t process_hookup; /* simix_global->process_list */
- s_xbt_swag_hookup_t synchro_hookup; /* {mutex,cond,sem}->sleeping */
- s_xbt_swag_hookup_t host_proc_hookup; /* smx_host->process_lis */
- s_xbt_swag_hookup_t destroy_hookup; /* simix_global->process_to_destroy */
-
- unsigned long pid;
- unsigned long ppid;
- char *name; /**< @brief process name if any */
- sg_host_t host; /* the host on which the process is running */
- smx_context_t context; /* the context (uctx/raw/thread) that executes the user function */
- xbt_running_ctx_t *running_ctx;
- unsigned doexception:1;
- unsigned blocked:1;
- unsigned suspended:1;
- unsigned auto_restart:1;
-
- sg_host_t new_host; /* if not null, the host on which the process must migrate to */
- smx_synchro_t waiting_synchro; /* the current blocking synchro if any */
- xbt_fifo_t comms; /* the current non-blocking communication synchros */
- xbt_dict_t properties;
+namespace simgrid {
+namespace simix {
+
+class Process {
+public:
+
+ // TODO, replace with boost intrusive container hooks
+ s_xbt_swag_hookup_t process_hookup = { nullptr, nullptr }; /* simix_global->process_list */
+ s_xbt_swag_hookup_t synchro_hookup = { nullptr, nullptr }; /* {mutex,cond,sem}->sleeping */
+ s_xbt_swag_hookup_t host_proc_hookup = { nullptr, nullptr }; /* smx_host->process_lis */
+ s_xbt_swag_hookup_t destroy_hookup = { nullptr, nullptr }; /* simix_global->process_to_destroy */
+
+ unsigned long pid = 0;
+ unsigned long ppid = 0;
+ char *name = nullptr; /**< @brief process name if any */
+ sg_host_t host = nullptr; /* the host on which the process is running */
+ smx_context_t context = nullptr; /* the context (uctx/raw/thread) that executes the user function */
+ xbt_running_ctx_t *running_ctx = nullptr;
+
+ // TODO, pack them
+ bool doexception = false;
+ bool blocked = false;
+ bool suspended = false;
+ bool auto_restart = false;
+
+ sg_host_t new_host = nullptr; /* if not null, the host on which the process must migrate to */
+ smx_synchro_t waiting_synchro = nullptr; /* the current blocking synchro if any */
+ xbt_fifo_t comms = nullptr; /* the current non-blocking communication synchros */
+ xbt_dict_t properties = nullptr;
s_smx_simcall_t simcall;
- void *data; /* kept for compatibility, it should be replaced with moddata */
- xbt_dynar_t on_exit; /* list of functions executed when the process dies */
+ void *data = nullptr; /* kept for compatibility, it should be replaced with moddata */
+ xbt_dynar_t on_exit = nullptr; /* list of functions executed when the process dies */
- xbt_main_func_t code;
- int argc;
- char **argv;
- smx_timer_t kill_timer;
- int segment_index; /*Reference to an SMPI process' data segment. Default value is -1 if not in SMPI context*/
-} s_smx_process_t;
+ xbt_main_func_t code = nullptr;
+ int argc = 0;
+ char **argv = nullptr;
+ smx_timer_t kill_timer = nullptr;
+ int segment_index = 0; /*Reference to an SMPI process' data segment. Default value is -1 if not in SMPI context*/
+};
+
+}
+}
+typedef simgrid::simix::Process* smx_process_t;
+
+SG_BEGIN_DECL()
XBT_PRIVATE smx_process_t SIMIX_process_create(
const char *name,
smx_mutex_t SIMIX_mutex_init(void)
{
XBT_IN("()");
- s_smx_process_t p; /* useful to initialize sleeping swag */
+ simgrid::simix::Process p; /* useful to initialize sleeping swag */
smx_mutex_t mutex = xbt_new0(s_smx_mutex_t, 1);
mutex->locked = 0;
smx_cond_t SIMIX_cond_init(void)
{
XBT_IN("()");
- s_smx_process_t p;
+ simgrid::simix::Process p;
smx_cond_t cond = xbt_new0(s_smx_cond_t, 1);
cond->sleeping = xbt_swag_new(xbt_swag_offset(p, synchro_hookup));
cond->mutex = NULL;
smx_sem_t SIMIX_sem_init(unsigned int value)
{
XBT_IN("(%u)",value);
- s_smx_process_t p;
+ simgrid::simix::Process p;
smx_sem_t sem = xbt_new0(s_smx_sem_t, 1);
sem->sleeping = xbt_swag_new(xbt_swag_offset(p, synchro_hookup));