Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Bugfix: Problems when we suspend/resume the process which is waiting on a semaphore.
authordonassbr <donassbr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 7 Apr 2010 18:58:45 +0000 (18:58 +0000)
committerdonassbr <donassbr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 7 Apr 2010 18:58:45 +0000 (18:58 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7470 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/simix/smx_process.c
src/simix/smx_synchro.c

index 0b341d3..c769cec 100644 (file)
@@ -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) {
index 7a27b49..77170c5 100644 (file)
@@ -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);