From: donassbr Date: Wed, 7 Apr 2010 18:58:45 +0000 (+0000) Subject: Bugfix: Problems when we suspend/resume the process which is waiting on a semaphore. X-Git-Tag: SVN~270 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/2a4cc87cb6c15c04bd73a1bad0e5cd98269db8ed Bugfix: Problems when we suspend/resume the process which is waiting on a semaphore. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7470 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index 0b341d3bc6..c769cecdb4 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -315,8 +315,8 @@ void SIMIX_process_suspend(smx_process_t process) if (process != SIMIX_process_self()) { - if (process->mutex) { - /* process blocked on a mutex, only set suspend=1 */ + if (process->mutex || process->sem) { + /* process blocked on a mutex or sem, only set suspend=1 */ process->suspended = 1; } else if (process->cond) { /* process blocked cond, suspend all actions */ @@ -369,8 +369,8 @@ void SIMIX_process_resume(smx_process_t process) if (process == SIMIX_process_self()) return; - if (process->mutex) { - DEBUG0("Resume process blocked on a mutex"); + if (process->mutex || process->sem) { + DEBUG0("Resume process blocked on a mutex or semaphore"); process->suspended = 0; /* It'll wake up by itself when mutex releases */ return; } else if (process->cond) { diff --git a/src/simix/smx_synchro.c b/src/simix/smx_synchro.c index 7a27b495a1..77170c58a2 100644 --- a/src/simix/smx_synchro.c +++ b/src/simix/smx_synchro.c @@ -552,11 +552,11 @@ unsigned int SIMIX_sem_acquire_any(xbt_dynar_t sems) { xbt_swag_insert(self, sem->sleeping); } SIMIX_process_yield(); + self->sem = NULL; while (self->suspended) SIMIX_process_yield(); /* one of the semaphore unsuspended us -- great, let's search which one (and get out of the others) */ - self->sem = NULL; xbt_dynar_foreach(sems,counter,sem) { if (xbt_swag_belongs(self,sem->sleeping)) xbt_swag_remove(self,sem->sleeping);