Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
The semaphore doesn't need to be shared between processes.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 21 Feb 2012 15:50:00 +0000 (16:50 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 21 Feb 2012 15:50:00 +0000 (16:50 +0100)
src/xbt/mmalloc/mm_module.c

index 2ba5796..5cb6084 100644 (file)
@@ -125,7 +125,7 @@ xbt_mheap_t xbt_mheap_new(int fd, void *baseaddr)
            mdp = (struct mdesc *) mtemp.base;
            mdp->fd = fd;
            if(!mdp->refcount){
            mdp = (struct mdesc *) mtemp.base;
            mdp->fd = fd;
            if(!mdp->refcount){
-             sem_init(&mdp->sem, 1, 1);
+              sem_init(&mdp->sem, 0, 1);
              mdp->refcount++;
            }
          }
              mdp->refcount++;
            }
          }
@@ -168,10 +168,8 @@ xbt_mheap_t xbt_mheap_new(int fd, void *baseaddr)
 
   if (mdp->fd < 0){
     mdp->flags |= MMALLOC_ANONYMOUS;
 
   if (mdp->fd < 0){
     mdp->flags |= MMALLOC_ANONYMOUS;
-    sem_init(&mdp->sem, 0, 1);
-  }else{
-    sem_init(&mdp->sem, 1, 1);
   }
   }
+  sem_init(&mdp->sem, 0, 1);
   
   /* If we have not been passed a valid open file descriptor for the file
      to map to, then open /dev/zero and use that to map to. */
   
   /* If we have not been passed a valid open file descriptor for the file
      to map to, then open /dev/zero and use that to map to. */