+ 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;
+
+ DEBUG2("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);
+ }
+
+ /* 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)
+{
+ surf_workstation_model->suspend(action->execution.surf_exec);
+}
+
+void SIMIX_host_execution_resume(smx_action_t action)
+{
+ 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*/
+ DEBUG0("SIMIX_execution_finished: execution successful");
+ break;
+
+ case SIMIX_FAILED:
+ TRY {
+ DEBUG1("SIMIX_execution_finished: host '%s' failed", req->issuer->smx_host->name);
+ THROW0(host_error, 0, "Host failed");
+ }
+ CATCH(req->issuer->running_ctx->exception) {
+ req->issuer->doexception = 1;
+ }
+ break;
+
+ case SIMIX_CANCELED:
+ TRY {
+ DEBUG0("SIMIX_execution_finished: execution canceled");
+ THROW0(cancel_error, 0, "Canceled");
+ }
+ CATCH(req->issuer->running_ctx->exception) {
+ req->issuer->doexception = 1;
+ }
+ break;
+
+ default:
+ THROW_IMPOSSIBLE;
+ }
+ req->issuer->waiting_action = NULL;
+ SIMIX_request_answer(req);
+ }
+}
+
+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);
+}