Coding styles fixes.
[TD_SE.git] / lecteursredacteurs / lecteursredacteurs.c
index a15e271ddea8a41aa4618f289b18d2c6e5b2a6bb..2c485d7d072390e1005292b7e70bba234f18a46b 100644 (file)
@@ -1,4 +1,6 @@
 #include <unistd.h>
+#include <pthread.h>
+#include <stdlib.h>
 #include <stdio.h>
 #include <semaphore.h>
 
@@ -25,7 +27,7 @@ static void *lecteur(void *arg)
                        sem_post(&redact);
                sem_post(&mutex);
        }
-    return NULL;
+       return NULL;
 }
 
 static void *redacteur(void *arg)
@@ -38,10 +40,18 @@ static void *redacteur(void *arg)
                sleep(2);
                sem_post(&redact);
        }
-    return NULL;
+       return NULL;
 }
 
 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;
 }