Skip to content
Extraits de code Groupes Projets
Valider 3e8d07e7 rédigé par Hugo Clercq's avatar Hugo Clercq
Parcourir les fichiers

trying to fix the deadlock

parent 24bdd93c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -315,14 +315,17 @@ void* produce(){
}
void* compute(){
while(done || buffer->size != 0) {
while(done || buffer->size != 0 ) {
long long number;
//start of critical area
printf("waiting compute\n");
sem_wait(&full);
pthread_mutex_lock(&mutex);
if(counter <=0){
pthread_mutex_unlock(&mutex);
sem_post(&empty);
sem_post(&full);
return NULL;
}
else{
number = pop(buffer);
......@@ -344,6 +347,7 @@ void* compute(){
printf("HIIIIII\n" );
pthread_mutex_unlock(&mutex2);
sem_post(&empty2);
sem_post(&full);
return NULL;
}
/*
......
......@@ -99,6 +99,7 @@ int main(int argc, char** argv){
//sem_post(&full);
//sem_wait(&empty);
//sem_post(&empty);
/*
sem_post(&full);
sem_post(&full);
sem_post(&full);
......@@ -106,6 +107,7 @@ int main(int argc, char** argv){
sem_post(&full);
sem_post(&full);
sem_post(&full);
*/
printf("------------ joined reader ---------------\n");
for(int i =0; i < Args.nThreads; i++){
......@@ -113,7 +115,9 @@ int main(int argc, char** argv){
printf("Error while joining one of the computing threads");
return EXIT_FAILURE;
}
printf("---------------------------------one thread finished\n");
}
/*
sem_post(&full2);
sem_post(&full2);
sem_post(&full2);
......@@ -121,6 +125,7 @@ int main(int argc, char** argv){
sem_post(&full2);
sem_post(&full2);
sem_post(&full2);
*/
done2=0;
printf("------------- joined compute ------------\n");
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter