#include "xbt/log.h"
#include "xbt/dict.h"
#include "mc/mc.h"
-#include "mc/mc_replay.h"
-#include "mc/mc_client.h"
+#include "src/mc/mc_replay.h"
+#include "src/mc/mc_client.h"
+#include "src/simix/smx_private.hpp"
#ifdef HAVE_SMPI
-#include "smpi/private.h"
+#include "src/smpi/private.h"
#endif
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_process, simix,
*
* \return The SIMIX process
*/
-XBT_INLINE smx_process_t SIMIX_process_self(void)
+smx_process_t SIMIX_process_self(void)
{
smx_context_t self_context = SIMIX_context_self();
/* cancel non-blocking communications */
smx_synchro_t synchro;
- while ((synchro = xbt_fifo_pop(process->comms))) {
+ while ((synchro = (smx_synchro_t) xbt_fifo_pop(process->comms))) {
/* make sure no one will finish the comm after this process is destroyed,
* because src_proc or dst_proc would be an invalid pointer */
{
smx_process_t process = NULL;
- while ((process = xbt_swag_extract(simix_global->process_to_destroy))) {
+ while ((process = (smx_process_t) xbt_swag_extract(simix_global->process_to_destroy))) {
XBT_DEBUG("Getting rid of %p",process);
SIMIX_context_free(process->context);
maestro->pid = simix_process_maxpid++;
maestro->ppid = -1;
maestro->name = (char *) "";
- maestro->running_ctx = xbt_new(xbt_running_ctx_t, 1);
+ maestro->running_ctx = (xbt_running_ctx_t*) xbt_malloc0(sizeof(xbt_running_ctx_t));
XBT_RUNNING_CTX_INITIALIZE(maestro->running_ctx);
maestro->context = SIMIX_context_new(NULL, 0, NULL, NULL, maestro);
maestro->simcall.issuer = maestro;
/* Add the process to the list of process to restart, only if
* the host is down
*/
- if (arg->auto_restart && !SIMIX_host_get_state(arg->host)) {
+ if (arg->auto_restart && !sg_host_get_state(arg->host)) {
SIMIX_host_add_auto_restart_process(arg->host,arg->name,arg->code, arg->data,
- sg_host_name(arg->host),
+ sg_host_get_name(arg->host),
SIMIX_timer_get_date(arg->kill_timer),
arg->argc,arg->argv,arg->properties,
arg->auto_restart);
}
- XBT_DEBUG("Process %s (%s) is dead",arg->name,sg_host_name(arg->host));
+ XBT_DEBUG("Process %s (%s) is dead",arg->name,sg_host_get_name(arg->host));
/* stop the context */
SIMIX_context_stop(arg->context);
}
kill_time, argc, argv, properties, auto_restart,
simcall->issuer);
}
+
+static void kill_process(void* process)
+{
+ simix_global->kill_process_function((smx_process_t) process);
+}
+
/**
* \brief Internal function to create a process.
*
XBT_DEBUG("Start process %s on host '%s'", name, hostname);
- if (!SIMIX_host_get_state(host)) {
+ if (!sg_host_get_state(host)) {
int i;
XBT_WARN("Cannot launch process '%s' on failed host '%s'", name,
hostname);
XBT_VERB("Create context %s", process->name);
process->context = SIMIX_context_new(code, argc, argv, simix_global->cleanup_process_function, process);
- process->running_ctx = xbt_new(xbt_running_ctx_t, 1);
+ process->running_ctx = (xbt_running_ctx_t*) xbt_malloc0(sizeof(xbt_running_ctx_t));
XBT_RUNNING_CTX_INITIALIZE(process->running_ctx);
if(MC_is_active()){
/* Now insert it in the global process list and in the process to run list */
xbt_swag_insert(process, simix_global->process_list);
- XBT_DEBUG("Inserting %s(%s) in the to_run list", process->name, sg_host_name(host));
+ XBT_DEBUG("Inserting %s(%s) in the to_run list", process->name, sg_host_get_name(host));
xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, process);
if (kill_time > SIMIX_get_clock() && simix_global->kill_process_function) {
XBT_DEBUG("Process %s(%s) will be kill at time %f", process->name,
- sg_host_name(process->host), kill_time);
- process->kill_timer = SIMIX_timer_set(kill_time, simix_global->kill_process_function, process);
+ sg_host_get_name(process->host), kill_time);
+ process->kill_timer = SIMIX_timer_set(kill_time, kill_process, process);
}
}
return process;
*/
void SIMIX_process_kill(smx_process_t process, smx_process_t issuer) {
- XBT_DEBUG("Killing process %s on %s", process->name, sg_host_name(process->host));
+ XBT_DEBUG("Killing process %s on %s", process->name, sg_host_get_name(process->host));
process->context->iwannadie = 1;
process->blocked = 0;
{
smx_process_t p = NULL;
- while ((p = xbt_swag_extract(simix_global->process_list))) {
+ while ((p = (smx_process_t) xbt_swag_extract(simix_global->process_list))) {
if (p != issuer) {
SIMIX_process_kill(p,issuer);
}
surf_action_cancel(sync->sleep.surf_sleep);
smx_simcall_t simcall;
- while ((simcall = xbt_fifo_shift(sync->simcalls))) {
+ while ((simcall = (smx_simcall_t) xbt_fifo_shift(sync->simcalls))) {
simcall_process_sleep__set__result(simcall, SIMIX_DONE);
simcall->issuer->waiting_synchro = NULL;
if (simcall->issuer->suspended) {
smx_synchro_t SIMIX_process_sleep(smx_process_t process, double duration)
{
- smx_synchro_t synchro;
sg_host_t host = process->host;
/* check if the host is active */
if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
- sg_host_name(host));
+ sg_host_get_name(host));
}
- synchro = xbt_mallocator_get(simix_global->synchro_mallocator);
+ smx_synchro_t synchro = (smx_synchro_t) xbt_mallocator_get(simix_global->synchro_mallocator);
synchro->type = SIMIX_SYNC_SLEEP;
synchro->name = NULL;
synchro->category = NULL;
e_smx_state_t state;
xbt_assert(synchro->type == SIMIX_SYNC_SLEEP || synchro->type == SIMIX_SYNC_JOIN);
- while ((simcall = xbt_fifo_shift(synchro->simcalls))) {
+ while ((simcall = (smx_simcall_t) xbt_fifo_shift(synchro->simcalls))) {
switch(surf_action_get_state(synchro->sleep.surf_sleep)){
case SURF_ACTION_FAILED:
smx_process_t SIMIX_process_from_PID(int PID)
{
smx_process_t proc;
- xbt_swag_foreach(proc, simix_global->process_list)
- {
- if(proc->pid == PID)
- return proc;
+ xbt_swag_foreach(proc, simix_global->process_list) {
+ if (proc->pid == (unsigned long) PID)
+ return proc;
}
return NULL;
}
}
/** @brief Restart a process, starting it again from the beginning. */
smx_process_t SIMIX_process_restart(smx_process_t process, smx_process_t issuer) {
- XBT_DEBUG("Restarting process %s on %s", process->name, sg_host_name(process->host));
+ XBT_DEBUG("Restarting process %s on %s", process->name, sg_host_get_name(process->host));
//retrieve the arguments of the old process
//FIXME: Factorize this with SIMIX_host_add_auto_restart_process ?
s_smx_process_arg_t arg;
arg.code = process->code;
- arg.hostname = sg_host_name(process->host);
+ arg.hostname = sg_host_get_name(process->host);
arg.kill_time = SIMIX_timer_get_date(process->kill_timer);
arg.argc = process->argc;
arg.data = process->data;