repositories
/
TD_SE.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Staticify some more.
[TD_SE.git]
/
semaphore
/
semaphore.c
diff --git
a/semaphore/semaphore.c
b/semaphore/semaphore.c
index 28eadbabae4f08ce631f99bd8250c09bf2c97933..53526d6fd6f37e2ddd3949e73c40fa67cb509e8c 100644
(file)
--- a/
semaphore/semaphore.c
+++ b/
semaphore/semaphore.c
@@
-4,7
+4,7
@@
#define val 1
sem_t mutex; // sémaphore
#define val 1
sem_t mutex; // sémaphore
-int var_glob = 0;
+
static
int var_glob = 0;
void *increment(void *);
void *decrement(void *);
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);
// 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;
}
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);
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)
}
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);
var_glob = var_glob + 1;
printf("ici sc de increment: var_glob= %d\n", var_glob);
sem_post(&mutex);
- return
(NULL)
;
+ return
NULL
;
}
}