gestion cas n_eat a zero

This commit is contained in:
Hugo LAMY
2022-01-26 18:58:39 +01:00
parent 232684b73a
commit e45ca1331f
4 changed files with 27 additions and 15 deletions

View File

@@ -6,7 +6,7 @@
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/26 15:30:28 by hulamy #+# #+# */
/* Updated: 2022/01/26 16:29:49 by hulamy ### ########.fr */
/* Updated: 2022/01/26 18:51:44 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -44,10 +44,8 @@ static int eat(t_philo *philo)
update_time(philo);
if (print_message(philo, B_YELLOW, "is eating"))
return (ret_err_unlock(philo, 2));
philo->eat_count++;
if (philo->eat_count == philo->params->n_eat)
philo->global->satiated_count++;
action_delay(philo, philo->params->t_eat);
philo->eat_count++;
pthread_mutex_unlock(&(philo->next->m_fork));
pthread_mutex_unlock(&(philo->m_fork));
return (0);