X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8d545185124c10e9c58d954d12103d6620e201d2..3203ed1f4fb6f4617e94d5351661ba07e8b8f833:/src/simix/smx_process.c diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index 8dbf2764f1..2fac9cf337 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -1,4 +1,4 @@ -/* 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 @@ -9,8 +9,8 @@ #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)"); @@ -182,8 +182,7 @@ void SIMIX_process_stop(smx_process_t arg) { */ 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, @@ -199,8 +198,7 @@ smx_process_t SIMIX_process_create_from_wrapper(smx_process_arg_t args) { } -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, @@ -209,7 +207,7 @@ void simcall_HANDLER_process_create(smx_simcall_t simcall, 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); } @@ -222,7 +220,7 @@ void simcall_HANDLER_process_create(smx_simcall_t simcall, * * \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, @@ -233,8 +231,8 @@ void SIMIX_process_create(smx_process_t *process, 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); @@ -247,60 +245,60 @@ void SIMIX_process_create(smx_process_t *process, 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, sg_host_simix(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; } /** @@ -350,7 +348,7 @@ void SIMIX_process_kill(smx_process_t process, smx_process_t issuer) { 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: @@ -407,7 +405,7 @@ void SIMIX_process_throw(smx_process_t process, xbt_errcat_t cat, int value, con 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: @@ -463,8 +461,7 @@ void SIMIX_process_killall(smx_process_t issuer, int reset_pid) 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; } @@ -540,7 +537,7 @@ smx_synchro_t SIMIX_process_suspend(smx_process_t process, smx_process_t issuer) } } 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); } } @@ -986,7 +983,7 @@ smx_process_t SIMIX_process_restart(smx_process_t process, smx_process_t issuer) //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, @@ -998,7 +995,7 @@ smx_process_t SIMIX_process_restart(smx_process_t process, smx_process_t issuer) arg.auto_restart, NULL); } else { - simcall_process_create(&new_process, + new_process = simcall_process_create( arg.argv[0], arg.code, arg.data,