-/*********************************** Mutex ************************************/
-smx_mutex_t SIMIX_mutex_init()
-{
- smx_mutex_t m = xbt_new0(s_smx_mutex_t,1);
- s_smx_process_t p; /* useful to initialize sleeping swag */
- /* structures initialization */
- m->using = 0;
- m->sleeping = xbt_swag_new(xbt_swag_offset(p, synchro_hookup));
- return m;
-}
-
-void SIMIX_mutex_lock(smx_mutex_t mutex)
-{
- smx_process_t self = SIMIX_process_self();
-
- xbt_assert0((mutex != NULL), "Invalid parameters");
-
- if (mutex->using) {
- /* somebody using the mutex, block */
- xbt_swag_insert(self, mutex->sleeping);
- self->simdata->mutex = mutex;
- /* wait for some process make the unlock and wake up me from mutex->sleeping */
- xbt_context_yield();
- /* verify if the process was suspended */
- while (self->simdata->suspended) {
- xbt_context_yield();
- }
-
- self->simdata->mutex = NULL;
- mutex->using = 1;
- }
- else {
- /* mutex free */
- mutex->using = 1;
- }
- return;
-}
-
-/* return 1 if the process got the mutex, else 0. */
-int SIMIX_mutex_trylock(smx_mutex_t mutex)
-{
- xbt_assert0((mutex != NULL), "Invalid parameters");
-
- if (mutex->using)
- return 0;
- else {
- mutex->using = 1;
- return 1;
- }
-}
-
-void SIMIX_mutex_unlock(smx_mutex_t mutex)
-{
- smx_process_t p; /*process to wake up */
-
- xbt_assert0((mutex != NULL), "Invalid parameters");
-
- if (xbt_swag_size(mutex->sleeping) > 0) {
- p = xbt_swag_extract(mutex->sleeping);
- mutex->using = 0;
- xbt_swag_insert(p, simix_global->process_to_run);
- }
- else {
- /* nobody to wake up */
- mutex->using = 0;
- }
- return;
+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;