Test and Set 2

This commit is contained in:
stersky 2022-11-22 15:13:53 +01:00
parent 33f71e89f6
commit ea7a712728

View file

@ -11,7 +11,6 @@
#include "iAcquisitionManager.h" #include "iAcquisitionManager.h"
#include "debug.h" #include "debug.h"
#include <stdatomic.h> #include <stdatomic.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#define gettid() syscall(SYS_gettid) #define gettid() syscall(SYS_gettid)
@ -73,21 +72,19 @@ static void pCountLockRelease(){
static unsigned int createSynchronizationObjects(void) static unsigned int createSynchronizationObjects(void)
{ {
//Initialisation des sémaphores int error;
semaphore_libre = sem_open("/acquisitionManager_semLibre", O_CREAT, 0644, BUFFER_SIZE);
if (semaphore_libre == SEM_FAILED) //TODO DONE
{ if((error = sem_init(&semaphore_libre, 0, BUFFER_SIZE)) < 0){
perror("[sem_open"); printf("[acquisitionManager]Semaphore L Error No. %d\n",error);
return ERROR_INIT; return error;
} }
semaphore_occupe = sem_open("/acquisitionManager_semLibre", O_CREAT, 0644, 0); if((error = sem_init(&semaphore_occupe, 0, 0)) < 0){
if (semaphore_occupe == SEM_FAILED) printf("[acquisitionManager]Semaphore O Error No. %d\n",error);
{ return error;
perror("[sem_open");
return ERROR_INIT;
} }
//----Fin de l'initialisation sémaphore -----
printf("[acquisitionManager]Semaphore created\n"); printf("[acquisitionManager]Semaphore created\n");
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }