From 151a0f5636afe11afad9428f737e71372a4c24e4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 1 Mar 2018 11:04:28 +0100 Subject: [PATCH] Staticify some more. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- TD3/exo4/exo4.c | 5 ++--- semaphore/semaphore.c | 8 ++++---- signal/signaux0.c | 2 +- threads/exemple1.c | 8 ++++---- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/TD3/exo4/exo4.c b/TD3/exo4/exo4.c index 40337f6..a5ffce3 100644 --- a/TD3/exo4/exo4.c +++ b/TD3/exo4/exo4.c @@ -35,14 +35,13 @@ int main(void) if (fork() == 0) { signal(SIGINT, sigintF); while (1) { - printf("ici fils \n"); + printf("ici fils\n"); sleep(1); } } while (1) { signal(SIGINT, sigintP); - printf("ici pere \n"); + printf("ici pere\n"); sleep(1); } - return 0; } diff --git a/semaphore/semaphore.c b/semaphore/semaphore.c index 28eadba..53526d6 100644 --- a/semaphore/semaphore.c +++ b/semaphore/semaphore.c @@ -4,7 +4,7 @@ #define val 1 sem_t mutex; // sémaphore -int var_glob = 0; +static int var_glob = 0; void *increment(void *); void *decrement(void *); @@ -21,7 +21,7 @@ int main() // 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; } @@ -31,7 +31,7 @@ void *decrement(void *nothing) 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) @@ -40,5 +40,5 @@ 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; } diff --git a/signal/signaux0.c b/signal/signaux0.c index 134d77e..c4db616 100644 --- a/signal/signaux0.c +++ b/signal/signaux0.c @@ -5,7 +5,7 @@ #include #include -int count = 0; +static int count = 0; static void action(int sig) { diff --git a/threads/exemple1.c b/threads/exemple1.c index d8cc0ed..571f7e1 100644 --- a/threads/exemple1.c +++ b/threads/exemple1.c @@ -6,7 +6,7 @@ #include #include -void afficher(int n, char lettre) +static void afficher(int n, char lettre) { int j; for (j = 1; j < n; j++) { @@ -15,7 +15,7 @@ void afficher(int n, char lettre) } } -void *threadA(void *inutilise) +static void *threadA(void *inutilise) { afficher(100, 'A'); printf("\n Fin du thread A\n"); @@ -23,7 +23,7 @@ void *threadA(void *inutilise) pthread_exit(NULL); } -void *threadC(void *inutilise) +static void *threadC(void *inutilise) { afficher(150, 'C'); printf("\n Fin du thread C\n"); @@ -31,7 +31,7 @@ void *threadC(void *inutilise) pthread_exit(NULL); } -void *threadB(void *inutilise) +static void *threadB(void *inutilise) { pthread_t thC; pthread_create(&thC, NULL, threadC, NULL); -- 2.34.1