static smx_action_t SIMIX_synchro_wait(smx_host_t smx_host, double timeout)
{
smx_action_t action;
- action = xbt_new0(s_smx_action_t, 1);
+ action = xbt_mallocator_get(simix_global->action_mallocator);
action->type = SIMIX_ACTION_SYNCHRO;
- action->request_list = xbt_fifo_new();
action->name = xbt_strdup("synchro");
action->synchro.sleep =
surf_workstation_model->extension.workstation.sleep(smx_host->host, timeout);
void SIMIX_synchro_destroy(smx_action_t action)
{
- DEBUG1("Destroying synchro %p", action);
+ XBT_DEBUG("Destroying synchro %p", action);
action->synchro.sleep->model_type->action_unref(action->synchro.sleep);
- xbt_fifo_free(action->request_list);
xbt_free(action->name);
- xbt_free(action);
+ xbt_mallocator_release(simix_global->action_mallocator, action);
}
void SIMIX_post_synchro(smx_action_t action)
else if(surf_workstation_model->action_state_get(action->synchro.sleep) == SURF_ACTION_DONE)
action->state = SIMIX_SRC_TIMEOUT;
- action->synchro.sleep->model_type->action_unref(action->synchro.sleep);
-
SIMIX_synchro_finish(action);
}
SIMIX_synchro_destroy(p->waiting_action);
p->waiting_action = NULL;
mutex->owner = p;
- SIMIX_request_answer(p->request);
+ SIMIX_request_answer(&p->request);
} else {
/* nobody to wake up */
mutex->locked = 0;
{
smx_action_t sync_act = NULL;
- DEBUG1("Wait condition %p", cond);
+ XBT_DEBUG("Wait condition %p", cond);
/* If there is a mutex unlock it */
/* FIXME: what happens if the issuer is not the owner of the mutex? */
smx_mutex_t mutex = NULL;
smx_req_t req = NULL;
- DEBUG1("Signal condition %p", cond);
+ XBT_DEBUG("Signal condition %p", cond);
/* If there are processes waiting for the condition choose one and try
to make it acquire the mutex */
proc->waiting_action = NULL;
/* Now transform the cond wait request into a mutex lock one */
- req = proc->request;
+ req = &proc->request;
if(req->call == REQ_COND_WAIT)
mutex = req->cond_wait.mutex;
else
*/
void SIMIX_cond_broadcast(smx_cond_t cond)
{
- DEBUG1("Broadcast condition %p", cond);
+ XBT_DEBUG("Broadcast condition %p", cond);
/* Signal the condition until nobody is waiting on it */
while (xbt_swag_size(cond->sleeping)) {
*/
void SIMIX_cond_destroy(smx_cond_t cond)
{
- DEBUG1("Destroy condition %p", cond);
+ XBT_DEBUG("Destroy condition %p", cond);
if (cond != NULL) {
xbt_assert0(xbt_swag_size(cond->sleeping) == 0,
/** @brief Destroys a semaphore */
void SIMIX_sem_destroy(smx_sem_t sem)
{
- DEBUG1("Destroy semaphore %p", sem);
+ XBT_DEBUG("Destroy semaphore %p", sem);
if (sem != NULL) {
xbt_assert0(xbt_swag_size(sem->sleeping) == 0,
"Cannot destroy semaphore since someone is still using it");
{
smx_process_t proc;
- DEBUG1("Sem release semaphore %p", sem);
+ XBT_DEBUG("Sem release semaphore %p", sem);
if ((proc = xbt_swag_extract(sem->sleeping))) {
proc = xbt_swag_extract(sem->sleeping);
SIMIX_synchro_destroy(proc->waiting_action);
proc->waiting_action = NULL;
- SIMIX_request_answer(proc->request);
+ SIMIX_request_answer(&proc->request);
} else if (sem->value < SMX_SEM_NOLIMIT) {
sem->value++;
}
{
smx_action_t sync_act = NULL;
- DEBUG2("Wait semaphore %p (timeout:%f)", sem, timeout);
+ XBT_DEBUG("Wait semaphore %p (timeout:%f)", sem, timeout);
if (sem->value <= 0) {
sync_act = SIMIX_synchro_wait(issuer->smx_host, timeout);
xbt_fifo_unshift(sync_act->request_list, req);