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

@@ -21,20 +21,21 @@ void update_time(t_philo *philo)
philo->t_last_meal.tu = stime.tv_usec;
}
int print_message(t_philo *philo, char *clr, char *msg, int key)
int print_message(t_philo *philo, char *clr, char *msg)
{
long int time_stamp;
struct timeval stime;
if (key)
return (1);
pthread_mutex_lock(&(philo->global->m_print));
if (philo->global->dead)
{
pthread_mutex_unlock(&(philo->global->m_print));
return (1);
}
gettimeofday(&stime, NULL);
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 %s%s\n", clr, time_stamp, philo->p_nbr, msg, RESET);
pthread_mutex_unlock(&(philo->global->m_print));
if (philo->global->dead)
return (1);
return (0);
}