From 0956af87cad34a981650642fb6648b2b265bd5e2 Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Wed, 24 May 2023 15:55:19 +0200 Subject: [PATCH] fix: data race --- philo/philo_routine.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/philo/philo_routine.c b/philo/philo_routine.c index 6b9c124..a11243c 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]); pthread_mutex_unlock(&data->forks[(philo->id + 1) % data->nb_philos]); if (check(philo, data)) return (1); - pthread_mutex_lock(&philo->last_eat_mutex); - pthread_mutex_unlock(&philo->last_eat_mutex); pthread_mutex_lock(&philo->nb_meal_mutex); philo->nb_meal++; pthread_mutex_unlock(&philo->nb_meal_mutex);