resolution erreur oublis unlock si dead + arret simulation si nombre death precise

This commit is contained in:
hugogogo
2022-01-26 08:19:12 +01:00
parent 475817540c
commit 03633fa5b2

View File

@@ -33,7 +33,10 @@ int is_dead(t_philo *philo, struct timeval stime)
if (philo->global->dead)
return (-1);
if (philo->params->n_eat != -1 && philo->eat >= philo->params->n_eat)
return (-1);
{
philo->global->dead = 1;
return (philo->p_nbr);
}
time = diff_time(philo->t_last_meal, stime);
if (time >= philo->params->t_die)
{
@@ -58,6 +61,7 @@ int print_message(t_philo *philo, char *clr, char *msg)
{
if (p_dead > 0)
ft_printf("%s%i %i died%s\n", B_RED, time_stamp, p_dead, RESET);
pthread_mutex_unlock(&(philo->global->m_print));
return (1);
}
else