From b553e5af978cd9b2e64a3d144f2f76d6115dc049 Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Thu, 20 Apr 2023 13:16:02 +0000 Subject: [PATCH] fix: stop when philo has enough eat --- main.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index 60cc592..754ed08 100644 --- a/main.c +++ b/main.c @@ -52,12 +52,6 @@ void *check_routine(t_data *data) while (true) { - if ((ssize_t) get_min_meal(data) == data->nb_meals) - { - stop(data); - printf("g pu faim\n"); - return (NULL); - } i = 0; while (i < data->nb_philos) { @@ -82,7 +76,12 @@ void *check_routine(t_data *data) return (NULL); } i++; - usleep(10); + if ((ssize_t) get_min_meal(data) >= data->nb_meals) + { + stop(data); + printf("g pu faim\n"); + return (NULL); + } } } }