+e_smx_state_t SIMIX_host_execution_get_state(smx_action_t action)
+{
+ return action->state;
+}
+
+void SIMIX_host_execution_set_priority(smx_action_t action, double priority)
+{
+ if(action->execution.surf_exec)
+ surf_workstation_model->set_priority(action->execution.surf_exec, priority);
+}
+
+void SIMIX_pre_host_execution_wait(smx_simcall_t simcall)
+{
+ smx_action_t action = simcall->host_execution_wait.execution;
+
+ XBT_DEBUG("Wait for execution of action %p, state %d", action, action->state);
+
+ /* Associate this simcall to the action */
+ xbt_fifo_push(action->simcalls, simcall);
+ simcall->issuer->waiting_action = action;
+
+ /* set surf's action */
+ if (MC_IS_ENABLED) {
+ action->state = SIMIX_DONE;
+ SIMIX_execution_finish(action);
+ return;
+ }
+
+ /* If the action is already finished then perform the error handling */
+ if (action->state != SIMIX_RUNNING)
+ SIMIX_execution_finish(action);
+}
+
+void SIMIX_host_execution_suspend(smx_action_t action)
+{
+ if(action->execution.surf_exec)
+ surf_workstation_model->suspend(action->execution.surf_exec);
+}
+
+void SIMIX_host_execution_resume(smx_action_t action)
+{
+ if(action->execution.surf_exec)
+ surf_workstation_model->suspend(action->execution.surf_exec);
+}
+
+void SIMIX_execution_finish(smx_action_t action)
+{
+ volatile xbt_fifo_item_t item;
+ smx_simcall_t simcall;
+
+ xbt_fifo_foreach(action->simcalls, item, simcall, smx_simcall_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", simcall->issuer->smx_host->name);
+ TRY {
+ THROWF(host_error, 0, "Host failed");
+ }
+ CATCH(simcall->issuer->running_ctx->exception) {
+ simcall->issuer->doexception = 1;
+ }
+ break;
+
+ case SIMIX_CANCELED:
+ XBT_DEBUG("SIMIX_execution_finished: execution canceled");
+ TRY {
+ THROWF(cancel_error, 0, "Canceled");
+ }
+ CATCH(simcall->issuer->running_ctx->exception) {
+ simcall->issuer->doexception = 1;
+ }
+ break;
+
+ default:
+ xbt_die("Internal error in SIMIX_execution_finish: unexpected action state %d",
+ action->state);
+ }
+ simcall->issuer->waiting_action = NULL;
+ simcall->host_execution_wait.result = action->state;
+ SIMIX_simcall_answer(simcall);
+ }
+
+ /* 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 canceled */
+ 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 simcalls associated with the action, then answer them */
+ if (xbt_fifo_size(action->simcalls)) {
+ 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