diff --git a/T2/tp/exercice-1/acquisitionManagerTestAndSet.c b/T2/tp/exercice-1/acquisitionManagerTestAndSet.c index 7922ff6..8d019eb 100755 --- a/T2/tp/exercice-1/acquisitionManagerTestAndSet.c +++ b/T2/tp/exercice-1/acquisitionManagerTestAndSet.c @@ -11,7 +11,6 @@ #include "iAcquisitionManager.h" #include "debug.h" #include - #include #define gettid() syscall(SYS_gettid) @@ -73,23 +72,21 @@ static void pCountLockRelease(){ static unsigned int createSynchronizationObjects(void) { - //Initialisation des sémaphores - semaphore_libre = sem_open("/acquisitionManager_semLibre", O_CREAT, 0644, BUFFER_SIZE); - if (semaphore_libre == SEM_FAILED) - { - perror("[sem_open"); - return ERROR_INIT; - } - - semaphore_occupe = sem_open("/acquisitionManager_semLibre", O_CREAT, 0644, 0); - if (semaphore_occupe == SEM_FAILED) - { - perror("[sem_open"); - return ERROR_INIT; - } - //----Fin de l'initialisation sémaphore ----- - printf("[acquisitionManager]Semaphore created\n"); - return ERROR_SUCCESS; + int error; + + //TODO DONE + if((error = sem_init(&semaphore_libre, 0, BUFFER_SIZE)) < 0){ + printf("[acquisitionManager]Semaphore L Error No. %d\n",error); + return error; + } + + if((error = sem_init(&semaphore_occupe, 0, 0)) < 0){ + printf("[acquisitionManager]Semaphore O Error No. %d\n",error); + return error; + } + + printf("[acquisitionManager]Semaphore created\n"); + return ERROR_SUCCESS; } static void incrementProducedCount(void)