X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d020b505257775756ee4ad1ae632a3bfe0e0c28a..70b06ee68762a9c1d43dcc20e2e33b977f5eb0cd:/src/simix/smx_synchro.c diff --git a/src/simix/smx_synchro.c b/src/simix/smx_synchro.c index 16ceb04ab4..aed9f50d2f 100644 --- a/src/simix/smx_synchro.c +++ b/src/simix/smx_synchro.c @@ -24,9 +24,8 @@ static void SIMIX_sem_block_onto(smx_sem_t sem); 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); @@ -66,11 +65,10 @@ void SIMIX_synchro_stop_waiting(smx_process_t process, smx_req_t req) 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) @@ -91,7 +89,7 @@ static void SIMIX_synchro_finish(smx_action_t action) case SIMIX_SRC_TIMEOUT: TRY { - THROW0(timeout_error, 0, "Synchro's wait timeout"); + THROWF(timeout_error, 0, "Synchro's wait timeout"); } CATCH(req->issuer->running_ctx->exception) { req->issuer->doexception = 1; } @@ -99,7 +97,7 @@ static void SIMIX_synchro_finish(smx_action_t action) case SIMIX_FAILED: TRY { - THROW0(host_error, 0, "Host failed"); + THROWF(host_error, 0, "Host failed"); } CATCH(req->issuer->running_ctx->exception) { req->issuer->doexception = 1; } @@ -272,7 +270,7 @@ static void _SIMIX_cond_wait(smx_cond_t cond, smx_mutex_t mutex, double timeout, { 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? */ @@ -300,7 +298,7 @@ void SIMIX_cond_signal(smx_cond_t cond) 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 */ @@ -333,7 +331,7 @@ void SIMIX_cond_signal(smx_cond_t cond) */ 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)) { @@ -349,10 +347,10 @@ void SIMIX_cond_broadcast(smx_cond_t cond) */ 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, + xbt_assert(xbt_swag_size(cond->sleeping) == 0, "Cannot destroy conditional since someone is still using it"); xbt_swag_free(cond->sleeping); @@ -376,9 +374,9 @@ smx_sem_t SIMIX_sem_init(unsigned int value) /** @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, + xbt_assert(xbt_swag_size(sem->sleeping) == 0, "Cannot destroy semaphore since someone is still using it"); xbt_swag_free(sem->sleeping); xbt_free(sem); @@ -394,7 +392,7 @@ void SIMIX_sem_release(smx_sem_t sem) { 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); @@ -422,7 +420,7 @@ static void _SIMIX_sem_wait(smx_sem_t sem, double timeout, smx_process_t issuer, { 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);