X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/568db0c9329e157e88f25ba85c515cb9f596f03a..74abcc1b52b7e7ec117d2472988bedfe2f40f5a2:/src/simix/smx_synchro.c?ds=sidebyside diff --git a/src/simix/smx_synchro.c b/src/simix/smx_synchro.c index 74fd1f0707..42d057bc6d 100644 --- a/src/simix/smx_synchro.c +++ b/src/simix/smx_synchro.c @@ -29,7 +29,7 @@ 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->refcount = 0; m->sleeping = xbt_swag_new(xbt_swag_offset(p, synchro_hookup)); return m; } @@ -46,7 +46,7 @@ void SIMIX_mutex_lock(smx_mutex_t mutex) xbt_assert0((mutex != NULL), "Invalid parameters"); - if (mutex->using) { + if (mutex->refcount ) { /* somebody using the mutex, block */ xbt_swag_insert(self, mutex->sleeping); self->simdata->mutex = mutex; @@ -59,10 +59,10 @@ void SIMIX_mutex_lock(smx_mutex_t mutex) xbt_context_yield(); } - mutex->using = 1; + mutex->refcount = 1; } else { /* mutex free */ - mutex->using = 1; + mutex->refcount = 1; } return; } @@ -78,10 +78,10 @@ int SIMIX_mutex_trylock(smx_mutex_t mutex) { xbt_assert0((mutex != NULL), "Invalid parameters"); - if (mutex->using) + if (mutex->refcount ) return 0; else { - mutex->using = 1; + mutex->refcount = 1; return 1; } } @@ -100,11 +100,11 @@ void SIMIX_mutex_unlock(smx_mutex_t mutex) if (xbt_swag_size(mutex->sleeping) > 0) { p = xbt_swag_extract(mutex->sleeping); - mutex->using = 0; + mutex->refcount = 0; xbt_swag_insert(p, simix_global->process_to_run); } else { /* nobody to wake up */ - mutex->using = 0; + mutex->refcount = 0; } return; } @@ -315,3 +315,17 @@ void SIMIX_cond_destroy(smx_cond_t cond) return; } } + +void SIMIX_cond_display_info(smx_cond_t cond) +{ + if (cond == NULL) + return; + else { + smx_process_t process = NULL; + + INFO0("Blocked process on this condition:"); + xbt_swag_foreach(process,cond->sleeping) { + INFO2("\t %s running on host %s",process->name,process->simdata->smx_host->name); + } + } +}