-/* Copyright (c) 2007-2014. The SimGrid Team.
+/* Copyright (c) 2007-2015. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#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"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_process, simix,
"Logging specific to SIMIX (process)");
XBT_DEBUG("%p should not be run anymore",process);
xbt_swag_remove(process, simix_global->process_list);
- xbt_swag_remove(process, SIMIX_host_priv(process->host)->process_list);
+ xbt_swag_remove(process, sg_host_simix(process->host)->process_list);
xbt_swag_insert(process, simix_global->process_to_destroy);
process->context->iwannadie = 0;
*/
smx_process_t SIMIX_process_create_from_wrapper(smx_process_arg_t args) {
- smx_process_t process;
- simix_global->create_process_function(&process,
+ smx_process_t process = simix_global->create_process_function(
args->name,
args->code,
args->data,
}
-void simcall_HANDLER_process_create(smx_simcall_t simcall,
- smx_process_t *process,
+void* simcall_HANDLER_process_create(smx_simcall_t simcall,
const char *name,
xbt_main_func_t code,
void *data,
int argc, char **argv,
xbt_dict_t properties,
int auto_restart){
- SIMIX_process_create(process, name, code, data, hostname,
+ return (void*)SIMIX_process_create(name, code, data, hostname,
kill_time, argc, argv, properties, auto_restart,
simcall->issuer);
}
*
* \return the process created
*/
-void SIMIX_process_create(smx_process_t *process,
+smx_process_t SIMIX_process_create(
const char *name,
xbt_main_func_t code,
void *data,
int auto_restart,
smx_process_t parent_process)
{
- *process = NULL;
- sg_host_t host = SIMIX_host_get_by_name(hostname);
+ smx_process_t process = NULL;
+ sg_host_t host = sg_host_by_name(hostname);
XBT_DEBUG("Start process %s on host '%s'", name, hostname);
xbt_free(argv);
}
else {
- *process = xbt_new0(s_smx_process_t, 1);
+ process = xbt_new0(s_smx_process_t, 1);
xbt_assert(((code != NULL) && (host != NULL)), "Invalid parameters");
/* Process data */
- (*process)->pid = simix_process_maxpid++;
- (*process)->name = xbt_strdup(name);
- (*process)->host = host;
- (*process)->data = data;
- (*process)->comms = xbt_fifo_new();
- (*process)->simcall.issuer = *process;
+ process->pid = simix_process_maxpid++;
+ process->name = xbt_strdup(name);
+ process->host = host;
+ process->data = data;
+ process->comms = xbt_fifo_new();
+ process->simcall.issuer = process;
if (parent_process) {
- (*process)->ppid = SIMIX_process_get_PID(parent_process);
+ process->ppid = SIMIX_process_get_PID(parent_process);
} else {
- (*process)->ppid = -1;
+ process->ppid = -1;
}
/* Process data for auto-restart */
- (*process)->auto_restart = auto_restart;
- (*process)->code = code;
- (*process)->argc = argc;
- (*process)->argv = argv;
+ process->auto_restart = auto_restart;
+ process->code = code;
+ process->argc = argc;
+ process->argv = argv;
- XBT_VERB("Create context %s", (*process)->name);
- (*process)->context = SIMIX_context_new(code, argc, argv,
- simix_global->cleanup_process_function, *process);
+ 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);
- XBT_RUNNING_CTX_INITIALIZE((*process)->running_ctx);
+ process->running_ctx = xbt_new(xbt_running_ctx_t, 1);
+ XBT_RUNNING_CTX_INITIALIZE(process->running_ctx);
if(MC_is_active()){
- MC_ignore_heap((*process)->running_ctx, sizeof(*(*process)->running_ctx));
+ MC_ignore_heap(process->running_ctx, sizeof(*process->running_ctx));
}
/* Add properties */
- (*process)->properties = properties;
+ process->properties = properties;
/* Add the process to it's host process list */
- xbt_swag_insert(*process, SIMIX_host_priv(host)->process_list);
+ xbt_swag_insert(process, sg_host_simix(host)->process_list);
- XBT_DEBUG("Start context '%s'", (*process)->name);
+ XBT_DEBUG("Start context '%s'", process->name);
/* 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_dynar_push_as(simix_global->process_to_run, smx_process_t, *process);
+ 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_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);
+ 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);
}
}
+ return process;
}
/**
case SIMIX_SYNC_EXECUTE:
case SIMIX_SYNC_PARALLEL_EXECUTE:
- SIMIX_host_execution_destroy(process->waiting_synchro);
+ SIMIX_process_execution_destroy(process->waiting_synchro);
break;
case SIMIX_SYNC_COMMUNICATE:
case SIMIX_SYNC_EXECUTE:
case SIMIX_SYNC_PARALLEL_EXECUTE:
- SIMIX_host_execution_cancel(process->waiting_synchro);
+ SIMIX_process_execution_cancel(process->waiting_synchro);
break;
case SIMIX_SYNC_COMMUNICATE:
SIMIX_process_empty_trash();
}
-void simcall_HANDLER_process_change_host(smx_simcall_t simcall, smx_process_t process,
- sg_host_t dest)
+void simcall_HANDLER_process_set_host(smx_simcall_t simcall, smx_process_t process, sg_host_t dest)
{
process->new_host = dest;
}
sg_host_t dest)
{
xbt_assert((process != NULL), "Invalid parameters");
- xbt_swag_remove(process, SIMIX_host_priv(process->host)->process_list);
+ xbt_swag_remove(process, sg_host_simix(process->host)->process_list);
process->host = dest;
- xbt_swag_insert(process, SIMIX_host_priv(dest)->process_list);
+ xbt_swag_insert(process, sg_host_simix(dest)->process_list);
}
}
} else {
/* FIXME: computation size is zero. Is it okay that bound is zero ? */
- return SIMIX_host_execute("suspend", process->host, 0.0, 1.0, 0.0, 0);
+ return SIMIX_process_execute(process, "suspend", 0.0, 1.0, 0.0, 0);
}
}
//start the new process
smx_process_t new_process;
if (simix_global->create_process_function) {
- simix_global->create_process_function(&new_process,
+ new_process = simix_global->create_process_function(
arg.argv[0],
arg.code,
arg.data,
arg.auto_restart,
NULL);
} else {
- simcall_process_create(&new_process,
+ new_process = simcall_process_create(
arg.argv[0],
arg.code,
arg.data,