From e4b5e6ea0db80af62f3d12f484baf70c24caf44f Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Thu, 25 May 2023 19:25:47 +0200 Subject: [PATCH] fix: update last_eat time after eat --- philo/philo_routine.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/philo/philo_routine.c b/philo/philo_routine.c index 57566df..142eede 100644 --- a/philo/philo_routine.c +++ b/philo/philo_routine.c @@ -6,7 +6,7 @@ /* By: cchauvet last_eat_mutex); - philo->last_eat = get_time(); - pthread_mutex_unlock(&philo->last_eat_mutex); print_eating(philo); usleep(get_time_eat(philo, data) * 1000); pthread_mutex_unlock(&data->forks[philo->id]); @@ -76,6 +73,9 @@ bool philo_eat(t_philo *philo, t_data *data) pthread_mutex_lock(&philo->nb_meal_mutex); philo->nb_meal++; pthread_mutex_unlock(&philo->nb_meal_mutex); + pthread_mutex_lock(&philo->last_eat_mutex); + philo->last_eat = get_time(); + pthread_mutex_unlock(&philo->last_eat_mutex); return (0); }