fonctionne ok sauf pour 1

This commit is contained in:
Hugo LAMY
2022-01-26 13:52:30 +01:00
parent 6561340fb9
commit 2f747d0563
4 changed files with 20 additions and 13 deletions

View File

@@ -8,6 +8,7 @@ int diff_time(t_time old, struct timeval new)
int is_dead(t_philo *philo)
{
struct timeval stime;
long int time_stamp;
int time;
if (philo->global->n_eat == philo->params->n_phi)
@@ -19,8 +20,13 @@ int is_dead(t_philo *philo)
time = diff_time(philo->t_last_meal, stime);
if (time >= philo->params->t_die)
{
pthread_mutex_lock(&(philo->global->m_print));
philo->global->dead = 1;
print_message(philo, B_RED, "died", 0);
time_stamp = (stime.tv_sec - philo->global->t_start.ts) * 1000;
time_stamp += (stime.tv_usec - philo->global->t_start.tu) / 1000;
ft_printf("%s%i %i died%s\n", B_RED, time_stamp, philo->p_nbr, RESET);
pthread_mutex_unlock(&(philo->global->m_print));
return (1);
}
return (0);