"SIMIX Synchronization (mutex, semaphores and conditions)");
static smx_synchro_t SIMIX_synchro_wait(sg_host_t smx_host, double timeout);
-static void SIMIX_synchro_finish(smx_synchro_t synchro);
static void _SIMIX_cond_wait(smx_cond_t cond, smx_mutex_t mutex, double timeout,
smx_process_t issuer, smx_simcall_t simcall);
static void _SIMIX_sem_wait(smx_sem_t sem, double timeout, smx_process_t issuer,
XBT_OUT();
}
-void SIMIX_synchro_destroy(smx_synchro_t synchro)
-{
- XBT_DEBUG("Destroying synchro %p", synchro);
- simgrid::simix::Raw *raw = static_cast<simgrid::simix::Raw*>(synchro);
-
- raw->sleep->unref();
- delete raw;
-}
-
-void SIMIX_post_synchro(smx_synchro_t synchro)
-{
- XBT_IN("(%p)",synchro);
- simgrid::simix::Raw *raw = static_cast<simgrid::simix::Raw*>(synchro);
- if (raw->sleep->getState() == simgrid::surf::Action::State::failed)
- raw->state = SIMIX_FAILED;
- else if(raw->sleep->getState() == simgrid::surf::Action::State::done)
- raw->state = SIMIX_SRC_TIMEOUT;
-
- SIMIX_synchro_finish(raw);
- XBT_OUT();
-}
-
-static void SIMIX_synchro_finish(smx_synchro_t synchro)
+void SIMIX_synchro_finish(smx_synchro_t synchro)
{
XBT_IN("(%p)",synchro);
smx_simcall_t simcall = (smx_simcall_t) xbt_fifo_shift(synchro->simcalls);
SIMIX_synchro_stop_waiting(simcall->issuer, simcall);
simcall->issuer->waiting_synchro = NULL;
- SIMIX_synchro_destroy(synchro);
+ delete synchro;
SIMIX_simcall_answer(simcall);
XBT_OUT();
}
if (xbt_swag_size(mutex->sleeping) > 0) {
/*process to wake up */
smx_process_t p = (smx_process_t) xbt_swag_extract(mutex->sleeping);
- SIMIX_synchro_destroy(p->waiting_synchro);
+ delete p->waiting_synchro;
p->waiting_synchro = NULL;
mutex->owner = p;
SIMIX_simcall_answer(&p->simcall);
if ((proc = (smx_process_t) xbt_swag_extract(cond->sleeping))) {
/* Destroy waiter's synchronization */
- SIMIX_synchro_destroy(proc->waiting_synchro);
+ delete proc->waiting_synchro;
proc->waiting_synchro = NULL;
/* Now transform the cond wait simcall into a mutex lock one */
XBT_DEBUG("Sem release semaphore %p", sem);
if ((proc = (smx_process_t) xbt_swag_extract(sem->sleeping))) {
- SIMIX_synchro_destroy(proc->waiting_synchro);
+ delete proc->waiting_synchro;
proc->waiting_synchro = NULL;
SIMIX_simcall_answer(&proc->simcall);
} else if (sem->value < SMX_SEM_NOLIMIT) {