Make the reader/writer code example work.
[TD_SE.git] / lecteursredacteurs / lecteursredacteurs.c
index a15e271ddea8a41aa4618f289b18d2c6e5b2a6bb..329be03a639f3ba515f717b63fac552a5c96703e 100644 (file)
@@ -1,4 +1,6 @@
 #include <unistd.h>
+#include <pthread.h>
+#include <stdlib.h>
 #include <stdio.h>
 #include <semaphore.h>
 
@@ -43,5 +45,13 @@ static void *redacteur(void *arg)
 
 int main()
 {
-
+       pthread_t t1, t2;
+       sem_init(&mutex, 0, 0);
+       sem_init(&redact, 0, 0);
+       pthread_create(&t1, NULL, redacteur, NULL);
+       pthread_create(&t2, NULL, lecteur, NULL);
+       pthread_join(t1, NULL);
+       pthread_join(t2, NULL);
+       printf("exit\n");
+       return EXIT_SUCCESS;
 }