xbt_fifo_free(process->comms);
+ xbt_dynar_free(&process->on_exit);
+
free(process->name);
free(process);
}
switch(surf_workstation_model->action_state_get(action->sleep.surf_sleep)){
case SURF_ACTION_FAILED:
- SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
+ simcall->issuer->context->iwannadie = 1;
+ //SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
break;
case SURF_ACTION_DONE:
THROW_IMPOSSIBLE;
break;
}
+ if (surf_workstation_model->extension.
+ workstation.get_state(simcall->issuer->smx_host->host) != SURF_RESOURCE_ON) {
+ simcall->issuer->context->iwannadie = 1;
+ }
simcall->process_sleep.result = state;
simcall->issuer->waiting_action = NULL;
SIMIX_simcall_answer(simcall);
+
}
SIMIX_process_sleep_destroy(action);
}
/* Ok, maestro returned control to us */
XBT_DEBUG("Control returned to me: '%s'", self->name);
+ if (self->new_host) {
+ SIMIX_process_change_host(self, self->new_host);
+ self->new_host = NULL;
+ }
+
if (self->context->iwannadie){
XBT_DEBUG("I wanna die!");
SIMIX_context_stop(self->context);
self->doexception = 0;
SMX_THROW();
}
-
- if (self->new_host) {
- SIMIX_process_change_host(self, self->new_host);
- self->new_host = NULL;
- }
}
/* callback: context fetching */
}
return res;
}
+void SIMIX_process_on_exit_runall(smx_process_t process) {
+ s_smx_process_exit_fun_t exit_fun;
+
+ while (!xbt_dynar_is_empty(process->on_exit)) {
+ exit_fun = xbt_dynar_pop_as(process->on_exit,s_smx_process_exit_fun_t);
+ (exit_fun.fun)(exit_fun.arg);
+ }
+}
+void SIMIX_process_on_exit(int_f_pvoid_t fun, void *data) {
+ smx_process_t process = SIMIX_process_self();
+ xbt_assert(process, "current process not found: are you in maestro context ?");
+
+ if (!process->on_exit) {
+ process->on_exit = xbt_dynar_new(sizeof(s_smx_process_exit_fun_t), NULL);
+ }
+
+ s_smx_process_exit_fun_t exit_fun = {fun, data};
+
+ xbt_dynar_push_as(process->on_exit,s_smx_process_exit_fun_t,exit_fun);
+}