#define val 1
sem_t mutex; // sémaphore
-int var_glob = 0;
+static int var_glob = 0;
void *increment(void *);
void *decrement(void *);
// attendre la fin des threads
pthread_join(threadA, NULL);
pthread_join(threadB, NULL);
- printf("ici main, fin threads : var_glob =%d \n", var_glob);
+ printf("ici main, fin threads : var_glob = %d\n", var_glob);
return 0;
}
var_glob = var_glob - 1;
printf("ici sc de decrement: var_glob= %d\n", var_glob);
sem_post(&mutex);
- return (NULL);
+ return NULL;
}
void *increment(void *nothing)
var_glob = var_glob + 1;
printf("ici sc de increment: var_glob= %d\n", var_glob);
sem_post(&mutex);
- return (NULL);
+ return NULL;
}