In order to configure the semaphore in C language under Linux, I wrote the following few lines of code:
int semid = semget(1234 , 2 , IPC_CREAT | 0666);
if(semid < 0)
printf("ERROR in semget \n ");
if( semctl(semid, 0, SETVAL, 1) < 0)
{
printf("ERROR in setting value of semaphore \n");
exit(EXIT_FAILURE);
}
But my software constantly displays the message: ERROR in semget ERROR in setting value of semaphore, and I’m not sure why.