X-Git-Url: https://git.piment-noir.org/?p=TD_SE.git;a=blobdiff_plain;f=semaphore%2Fsemaphore.c;h=53526d6fd6f37e2ddd3949e73c40fa67cb509e8c;hp=28eadbabae4f08ce631f99bd8250c09bf2c97933;hb=151a0f5636afe11afad9428f737e71372a4c24e4;hpb=4ed359e8f4a3ded5357fd63f276dafec2642cb57 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; }