diff --git a/philo.c b/philo.c index 44a24de..65424d8 100644 --- a/philo.c +++ b/philo.c @@ -42,6 +42,12 @@ bool philo_eat(t_philo *philo, t_data *data) pthread_mutex_unlock(&data->forks[philo->id]); return (1); } + while ((philo->id + 1) % data->nb_philos == philo->id) + if (check(philo, data)) + { + pthread_mutex_unlock(&data->forks[philo->id]); + return (1); + } pthread_mutex_lock(&data->forks[(philo->id + 1) % data->nb_philos]); print_take_a_fork(philo); if (check(philo, data))