+
+void SIMIX_execution_finish(smx_action_t action)
+{
+ volatile xbt_fifo_item_t item;
+ smx_req_t req;
+
+ xbt_fifo_foreach(action->request_list, item, req, smx_req_t) {
+
+ switch (action->state) {
+
+ case SIMIX_DONE:
+ /* do nothing, action done */
+ XBT_DEBUG("SIMIX_execution_finished: execution successful");
+ break;
+
+ case SIMIX_FAILED:
+ XBT_DEBUG("SIMIX_execution_finished: host '%s' failed", req->issuer->smx_host->name);
+ TRY {
+ THROWF(host_error, 0, "Host failed");
+ }
+ CATCH(req->issuer->running_ctx->exception) {
+ req->issuer->doexception = 1;
+ }
+ break;
+
+ case SIMIX_CANCELED:
+ XBT_DEBUG("SIMIX_execution_finished: execution canceled");
+ TRY {
+ THROWF(cancel_error, 0, "Canceled");
+ }
+ CATCH(req->issuer->running_ctx->exception) {
+ req->issuer->doexception = 1;
+ }
+ break;
+
+ default:
+ xbt_die("Internal error in SIMIX_execution_finish: unexpected action state %d",
+ action->state);
+ }
+ req->issuer->waiting_action = NULL;
+ req->host_execution_wait.result = action->state;
+ SIMIX_request_answer(req);
+ }
+
+ /* We no longer need it */
+ SIMIX_host_execution_destroy(action);
+}
+
+void SIMIX_post_host_execute(smx_action_t action)
+{
+ /* FIXME: check if the host running the action failed or not*/
+ /*if(surf_workstation_model->extension.workstation.get_state(action->host->host))*/
+
+ /* If the host running the action didn't fail, then the action was cancelled */
+ if (surf_workstation_model->action_state_get(action->execution.surf_exec) == SURF_ACTION_FAILED)
+ action->state = SIMIX_CANCELED;
+ else
+ action->state = SIMIX_DONE;
+
+ if (action->execution.surf_exec) {
+ surf_workstation_model->action_unref(action->execution.surf_exec);
+ action->execution.surf_exec = NULL;
+ }
+
+ /* If there are requests associated with the action, then answer them */
+ if (xbt_fifo_size(action->request_list))
+ SIMIX_execution_finish(action);
+}
+
+
+#ifdef HAVE_TRACING
+void SIMIX_set_category(smx_action_t action, const char *category)
+{
+ if (action->state != SIMIX_RUNNING) return;
+ if (action->type == SIMIX_ACTION_EXECUTE){
+ surf_workstation_model->set_category(action->execution.surf_exec, category);
+ }else if (action->type == SIMIX_ACTION_COMMUNICATE){
+ surf_workstation_model->set_category(action->comm.surf_comm, category);
+ }
+}
+#endif
+