X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9ef6657fec2b0eacbd273c2e3a53dc9f4fb2c8a0..cd69f8c66886ae218c6a9b38125b27fe157e6bb2:/src/simix/smx_process.c diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index 60fc8a6abd..ddc96427bf 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -64,20 +64,12 @@ void SIMIX_process_cleanup(smx_process_t process) action, action->comm.detached, (int)action->state, action->comm.src_proc, action->comm.dst_proc); action->comm.src_proc = NULL; - if (action->comm.detached) { - if (action->comm.refcount == 0) { - XBT_DEBUG("Increase the refcount before destroying it since it's detached"); - /* I'm not supposed to destroy a detached comm from the sender side, - * unless there is no receiver matching the rdv */ - action->comm.refcount++; - SIMIX_comm_destroy(action); - } - else { - XBT_DEBUG("Don't destroy it since its refcount is %d", action->comm.refcount); - } - } else { + /* I'm not supposed to destroy a detached comm from the sender side, */ + if (!action->comm.detached) SIMIX_comm_destroy(action); - } + else + XBT_DEBUG("Don't destroy it since it's a detached comm"); + } else if (action->comm.dst_proc == process){ XBT_DEBUG("Found an unfinished recv comm %p, state %d, src = %p, dst = %p", @@ -293,10 +285,8 @@ void SIMIX_process_create(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()) { - if (simix_global->kill_process_function) { + 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)->smx_host), kill_time); SIMIX_timer_set(kill_time, simix_global->kill_process_function, *process); @@ -342,7 +332,7 @@ void SIMIX_process_kill(smx_process_t process, smx_process_t issuer) { process->context->iwannadie = 1; process->blocked = 0; process->suspended = 0; - /* FIXME: set doexception to 0 also? */ + process->doexception = 0; /* destroy the blocking action if any */ if (process->waiting_action) { @@ -377,13 +367,6 @@ void SIMIX_process_kill(smx_process_t process, smx_process_t issuer) { SIMIX_io_destroy(process->waiting_action); break; - /* **************************************/ - /* TUTORIAL: New API */ - case SIMIX_ACTION_NEW_API: - SIMIX_new_api_destroy(process->waiting_action); - break; - /* **************************************/ - } } if(!xbt_dynar_member(simix_global->process_to_run, &(process)) && process != issuer) { @@ -392,6 +375,57 @@ void SIMIX_process_kill(smx_process_t process, smx_process_t issuer) { } +/** @brief Ask another process to raise the given exception + * + * @param cat category of exception + * @param value value associated to the exception + * @param msg string information associated to the exception + */ +void SIMIX_process_throw(smx_process_t process, xbt_errcat_t cat, int value, const char *msg) { + SMX_EXCEPTION(process, cat, value, msg); + + if (process->suspended) + SIMIX_process_resume(process,SIMIX_process_self()); + + /* cancel the blocking action if any */ + if (process->waiting_action) { + + switch (process->waiting_action->type) { + + case SIMIX_ACTION_EXECUTE: + case SIMIX_ACTION_PARALLEL_EXECUTE: + SIMIX_host_execution_cancel(process->waiting_action); + break; + + case SIMIX_ACTION_COMMUNICATE: + xbt_fifo_remove(process->comms, process->waiting_action); + SIMIX_comm_cancel(process->waiting_action); + break; + + case SIMIX_ACTION_SLEEP: + SIMIX_process_sleep_destroy(process->waiting_action); + break; + + case SIMIX_ACTION_JOIN: + SIMIX_process_sleep_destroy(process->waiting_action); + break; + + case SIMIX_ACTION_SYNCHRO: + SIMIX_synchro_stop_waiting(process, &process->simcall); + break; + + case SIMIX_ACTION_IO: + SIMIX_io_destroy(process->waiting_action); + break; + + } + } + process->waiting_action = NULL; + + if (!xbt_dynar_member(simix_global->process_to_run, &(process)) && process != SIMIX_process_self()) + xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, process); +} + void SIMIX_pre_process_killall(smx_simcall_t simcall, int reset_pid) { SIMIX_process_killall(simcall->issuer, reset_pid); } @@ -504,8 +538,6 @@ void SIMIX_pre_process_resume(smx_simcall_t simcall, smx_process_t process){ void SIMIX_process_resume(smx_process_t process, smx_process_t issuer) { - xbt_assert((process != NULL), "Invalid parameters"); - XBT_IN("process = %p, issuer = %p", process, issuer); if(process->context->iwannadie) { @@ -854,7 +886,7 @@ void SIMIX_process_yield(smx_process_t self) if (self->suspended) { XBT_DEBUG("Hey! I'm suspended."); - xbt_assert(!self->doexception, "Gloups! This exception may be lost by subsequent calls."); + xbt_assert(!self->doexception, "Gasp! This exception may be lost by subsequent calls."); self->suspended = 0; SIMIX_process_suspend(self, self); }