I created a class "semaphore" with a method "reader" this way:
void semaforo::reader(sem_t x, sem_t y,sem_t z,sem_t rsem,sem_t wsem){
cout<<"----------------"<<endl;
cout<<"Leitor esta Lendo"<<endl;
sem_wait(&z);
sem_wait(&rsem);
sem_wait(&x);
int aux = readcountM(0);
if(aux ==1){
sem_wait(&wsem);
}
sem_post(&x);
sem_post(&rsem);
sem_post(&z);
prints(1);
sem_wait(&x);
aux = readcountN(aux);
if(aux == 0){
sem_post(&wsem);
}
sem_post(&x);
}
In my main.cpp, I created these auxiliary variables, and instanced my class as follows:
You cannot use the non-existent value returned by a function with a return type of void. There is no such value.
It's hard to know how you can rewrite the code correctly since we don't have the relevant information. If thread::pthread_creation is an analog to pthread_create it seems likely you don't have a function with the correct signature to use in the call.