#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;
}
#include <stdlib.h>
#include <stdio.h>
-void afficher(int n, char lettre)
+static void afficher(int n, char lettre)
{
int j;
for (j = 1; j < n; j++) {
}
}
-void *threadA(void *inutilise)
+static void *threadA(void *inutilise)
{
afficher(100, 'A');
printf("\n Fin du thread A\n");
pthread_exit(NULL);
}
-void *threadC(void *inutilise)
+static void *threadC(void *inutilise)
{
afficher(150, 'C');
printf("\n Fin du thread C\n");
pthread_exit(NULL);
}
-void *threadB(void *inutilise)
+static void *threadB(void *inutilise)
{
pthread_t thC;
pthread_create(&thC, NULL, threadC, NULL);