+xbt_dict_t SIMIX_process_get_properties(smx_process_t process)
+{
+ return process->properties;
+}
+
+void SIMIX_pre_process_sleep(smx_simcall_t simcall)
+{
+ if (MC_is_active()) {
+ MC_process_clock_add(simcall->issuer, simcall->process_sleep.duration);
+ simcall->process_sleep.result = SIMIX_DONE;
+ SIMIX_simcall_answer(simcall);
+ return;
+ }
+ smx_action_t action = SIMIX_process_sleep(simcall->issuer, simcall->process_sleep.duration);
+ xbt_fifo_push(action->simcalls, simcall);
+ simcall->issuer->waiting_action = action;
+}
+
+smx_action_t SIMIX_process_sleep(smx_process_t process, double duration)
+{
+ smx_action_t action;
+ smx_host_t host = process->smx_host;
+
+ /* check if the host is active */
+ if (surf_workstation_model->extension.
+ workstation.get_state(host->host) != SURF_RESOURCE_ON) {
+ THROWF(host_error, 0, "Host %s failed, you cannot call this function",
+ host->name);
+ }
+
+ action = xbt_mallocator_get(simix_global->action_mallocator);
+ action->type = SIMIX_ACTION_SLEEP;
+ action->name = NULL;
+#ifdef HAVE_TRACING
+ action->category = NULL;
+#endif
+
+ action->sleep.host = host;
+ action->sleep.surf_sleep =
+ surf_workstation_model->extension.workstation.sleep(host->host, duration);
+
+ surf_workstation_model->action_data_set(action->sleep.surf_sleep, action);
+ XBT_DEBUG("Create sleep action %p", action);
+
+ return action;
+}
+
+void SIMIX_post_process_sleep(smx_action_t action)
+{
+ smx_simcall_t simcall;
+ e_smx_state_t state;
+
+ while ((simcall = xbt_fifo_shift(action->simcalls))) {
+
+ switch(surf_workstation_model->action_state_get(action->sleep.surf_sleep)){
+ case SURF_ACTION_FAILED:
+ simcall->issuer->context->iwannadie = 1;
+ //SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
+ break;
+
+ case SURF_ACTION_DONE:
+ state = SIMIX_DONE;
+ break;
+
+ default:
+ 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);
+}
+
+void SIMIX_process_sleep_destroy(smx_action_t action)
+{
+ XBT_DEBUG("Destroy action %p", action);
+ if (action->sleep.surf_sleep)
+ action->sleep.surf_sleep->model_type->action_unref(action->sleep.surf_sleep);
+ xbt_mallocator_release(simix_global->action_mallocator, action);
+}
+
+void SIMIX_process_sleep_suspend(smx_action_t action)
+{
+ surf_workstation_model->suspend(action->sleep.surf_sleep);
+}
+
+void SIMIX_process_sleep_resume(smx_action_t action)
+{
+ surf_workstation_model->resume(action->sleep.surf_sleep);
+}
+
+/**
+ * \brief Calling this function makes the process to yield.
+ *
+ * Only the current process can call this function, giving back the control to
+ * maestro.