+static smx_action_t SIMIX_synchro_wait(smx_host_t smx_host, double timeout);
+static void SIMIX_synchro_finish(smx_action_t action);
+static void _SIMIX_cond_wait(smx_cond_t cond, smx_mutex_t mutex, double timeout,
+ smx_process_t issuer, smx_req_t req);
+static void _SIMIX_sem_wait(smx_sem_t sem, double timeout, smx_process_t issuer,
+ smx_req_t req);
+static void SIMIX_sem_block_onto(smx_sem_t sem);
+
+/***************************** Synchro action *********************************/
+
+static smx_action_t SIMIX_synchro_wait(smx_host_t smx_host, double timeout)
+{
+ XBT_IN("(%p, %f)",smx_host,timeout);
+ smx_action_t action;
+ action = xbt_mallocator_get(simix_global->action_mallocator);
+ action->type = SIMIX_ACTION_SYNCHRO;
+ action->name = xbt_strdup("synchro");
+ action->synchro.sleep =
+ surf_workstation_model->extension.workstation.sleep(smx_host->host, timeout);
+
+ surf_workstation_model->action_data_set(action->synchro.sleep, action);
+ XBT_OUT();
+ return action;
+}
+
+void SIMIX_synchro_stop_waiting(smx_process_t process, smx_req_t req)
+{
+ XBT_IN("(%p, %p)",process,req);
+ switch (req->call) {
+
+ case REQ_MUTEX_LOCK:
+ xbt_swag_remove(process, req->mutex_lock.mutex->sleeping);
+ break;
+
+ case REQ_COND_WAIT:
+ xbt_swag_remove(process, req->cond_wait.cond->sleeping);
+ break;
+
+ case REQ_COND_WAIT_TIMEOUT:
+ xbt_swag_remove(process, req->cond_wait_timeout.cond->sleeping);
+ break;
+
+ case REQ_SEM_ACQUIRE:
+ xbt_swag_remove(process, req->sem_acquire.sem->sleeping);
+ break;
+
+ case REQ_SEM_ACQUIRE_TIMEOUT:
+ xbt_swag_remove(process, req->sem_acquire_timeout.sem->sleeping);
+ break;
+
+ default:
+ THROW_IMPOSSIBLE;
+ }
+ XBT_OUT();
+}
+
+void SIMIX_synchro_destroy(smx_action_t action)
+{
+ XBT_IN("(%p)",action);
+ XBT_DEBUG("Destroying synchro %p", action);
+ action->synchro.sleep->model_type->action_unref(action->synchro.sleep);
+ xbt_free(action->name);
+ xbt_mallocator_release(simix_global->action_mallocator, action);
+ XBT_OUT();
+}
+
+void SIMIX_post_synchro(smx_action_t action)
+{
+ XBT_IN("(%p)",action);
+ if (surf_workstation_model->action_state_get(action->synchro.sleep) == SURF_ACTION_FAILED)
+ action->state = SIMIX_FAILED;
+ else if(surf_workstation_model->action_state_get(action->synchro.sleep) == SURF_ACTION_DONE)
+ action->state = SIMIX_SRC_TIMEOUT;
+
+ SIMIX_synchro_finish(action);
+ XBT_OUT();
+}