fonctionne ok sauf pour 1
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user