+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_req_t req)
+{
+ smx_action_t action = req->host_execution_wait.execution;
+
+ XBT_DEBUG("Wait for execution of action %p, state %d", action, action->state);
+
+ /* Associate this request to the action */
+ xbt_fifo_push(action->request_list, req);
+ req->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)
+{
+ 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:
+ TRY {
+ XBT_DEBUG("SIMIX_execution_finished: host '%s' failed", req->issuer->smx_host->name);
+ THROWF(host_error, 0, "Host failed");
+ }
+ CATCH(req->issuer->running_ctx->exception) {
+ req->issuer->doexception = 1;
+ }
+ break;
+
+ case SIMIX_CANCELED:
+ TRY {
+ XBT_DEBUG("SIMIX_execution_finished: execution canceled");
+ THROWF(cancel_error, 0, "Canceled");
+ }
+ CATCH(req->issuer->running_ctx->exception) {
+ req->issuer->doexception = 1;
+ }
+ break;
+
+ default:
+ THROW_IMPOSSIBLE;
+ }
+ 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