X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e99350b90a8c0e400db2f43e3093b70afdbd2aac..b661d99ad7665d468164a2f957125429515ebf20:/src/simix/smx_process.c diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index 01df49c494..168a00ff23 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -35,7 +35,7 @@ XBT_INLINE smx_process_t SIMIX_process_self(void) */ void SIMIX_process_cleanup(smx_process_t process) { - DEBUG1("Cleanup process %s", process->name); + XBT_DEBUG("Cleanup process %s", process->name); /*xbt_swag_remove(process, simix_global->process_to_run);*/ xbt_swag_remove(process, simix_global->process_list); xbt_swag_remove(process, process->smx_host->process_list); @@ -94,31 +94,15 @@ void SIMIX_create_maestro_process() smx_process_t SIMIX_process_create_from_wrapper(smx_process_arg_t args) { smx_process_t process; - - if (simix_global->create_process_function) { - simix_global->create_process_function( - &process, - args->name, - args->code, - args->data, - args->hostname, - args->argc, - args->argv, - args->properties); - } - else { - SIMIX_process_create( - &process, - args->name, - args->code, - args->data, - args->hostname, - args->argc, - args->argv, - args->properties); - } - // FIXME: to simplify this, simix_global->create_process_function could just - // be SIMIX_process_create() by default (and the same thing in smx_deployment.c) + simix_global->create_process_function( + &process, + args->name, + args->code, + args->data, + args->hostname, + args->argc, + args->argv, + args->properties); return process; } @@ -143,10 +127,10 @@ void SIMIX_process_create(smx_process_t *process, *process = NULL; smx_host_t host = SIMIX_host_get_by_name(hostname); - DEBUG2("Start process %s on host %s", name, hostname); + XBT_DEBUG("Start process %s on host %s", name, hostname); if (!SIMIX_host_get_state(host)) { - WARN2("Cannot launch process '%s' on failed host '%s'", name, + XBT_WARN("Cannot launch process '%s' on failed host '%s'", name, hostname); } else { @@ -160,7 +144,7 @@ void SIMIX_process_create(smx_process_t *process, (*process)->smx_host = host; (*process)->data = data; - VERB1("Create context %s", (*process)->name); + XBT_VERB("Create context %s", (*process)->name); (*process)->context = SIMIX_context_new(code, argc, argv, simix_global->cleanup_process_function, *process); @@ -173,11 +157,11 @@ void SIMIX_process_create(smx_process_t *process, /* Add the process to it's host process list */ xbt_swag_insert(*process, host->process_list); - DEBUG1("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); - DEBUG2("Inserting %s(%s) in the to_run list", (*process)->name, host->name); + XBT_DEBUG("Inserting %s(%s) in the to_run list", (*process)->name, host->name); xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, *process); } } @@ -190,9 +174,9 @@ void SIMIX_process_create(smx_process_t *process, * * \param process poor victim */ -void SIMIX_process_kill(smx_process_t process, smx_process_t killer) { +void SIMIX_process_kill(smx_process_t process) { - DEBUG2("Killing process %s on %s", process->name, process->smx_host->name); + XBT_DEBUG("Killing process %s on %s", process->name, process->smx_host->name); process->context->iwannadie = 1; process->blocked = 0; @@ -227,26 +211,22 @@ void SIMIX_process_kill(smx_process_t process, smx_process_t killer) { } } - /* If I'm killing myself then stop, otherwise schedule the process to kill. */ - if (process == killer) { - SIMIX_context_stop(process->context); - } - else { - xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, process); - } + xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, process); } /** * \brief Kills all running processes. - * - * Only maestro can kill everyone. + * \param issuer this one will not be killed */ -void SIMIX_process_killall(void) +void SIMIX_process_killall(smx_process_t issuer) { smx_process_t p = NULL; - while ((p = xbt_swag_extract(simix_global->process_list))) - SIMIX_process_kill(p, SIMIX_process_self()); + while ((p = xbt_swag_extract(simix_global->process_list))) { + if (p != issuer) { + SIMIX_process_kill(p); + } + } SIMIX_context_runall(simix_global->process_to_run); @@ -349,6 +329,7 @@ void SIMIX_process_resume(smx_process_t process, smx_process_t issuer) int SIMIX_process_get_maxpid(void) { return simix_process_maxpid; } + int SIMIX_process_count(void) { return xbt_swag_size(simix_global->process_list); @@ -399,6 +380,18 @@ const char* SIMIX_process_get_name(smx_process_t process) return process->name; } +smx_process_t SIMIX_process_get_by_name(const char* name) +{ + smx_process_t proc; + + xbt_swag_foreach(proc, simix_global->process_list) + { + if(!strcmp(name, proc->name)) + return proc; + } + return NULL; +} + int SIMIX_process_is_suspended(smx_process_t process) { return process->suspended; @@ -436,7 +429,7 @@ smx_action_t SIMIX_process_sleep(smx_process_t process, double duration) action = xbt_mallocator_get(simix_global->action_mallocator); action->type = SIMIX_ACTION_SLEEP; - action->name = xbt_strdup("sleep"); + action->name = NULL; #ifdef HAVE_TRACING action->category = NULL; #endif @@ -446,7 +439,7 @@ smx_action_t SIMIX_process_sleep(smx_process_t process, double duration) surf_workstation_model->extension.workstation.sleep(host->host, duration); surf_workstation_model->action_data_set(action->sleep.surf_sleep, action); - DEBUG1("Create sleep action %p", action); + XBT_DEBUG("Create sleep action %p", action); return action; } @@ -480,8 +473,7 @@ void SIMIX_post_process_sleep(smx_action_t action) void SIMIX_process_sleep_destroy(smx_action_t action) { - DEBUG1("Destroy action %p", action); - xbt_free(action->name); + XBT_DEBUG("Destroy action %p", action); if (action->sleep.surf_sleep) action->sleep.surf_sleep->model_type->action_unref(action->sleep.surf_sleep); #ifdef HAVE_TRACING @@ -508,21 +500,21 @@ void SIMIX_process_yield(void) { smx_process_t self = SIMIX_process_self(); - DEBUG1("Yield process '%s'", self->name); + XBT_DEBUG("Yield process '%s'", self->name); /* Go into sleep and return control to maestro */ SIMIX_context_suspend(self->context); /* Ok, maestro returned control to us */ - DEBUG1("Maestro returned control to me: '%s'", self->name); + XBT_DEBUG("Maestro returned control to me: '%s'", self->name); if (self->context->iwannadie){ - DEBUG0("I wanna die!"); + XBT_DEBUG("I wanna die!"); SIMIX_context_stop(self->context); } if (self->doexception) { - DEBUG0("Wait, maestro left me an exception"); + XBT_DEBUG("Wait, maestro left me an exception"); self->doexception = 0; RETHROW; } @@ -544,6 +536,7 @@ void SIMIX_process_exception_terminate(xbt_ex_t * e) smx_context_t SIMIX_process_get_context(smx_process_t p) { return p->context; } + void SIMIX_process_set_context(smx_process_t p,smx_context_t c) { p->context = c; }