meilleur organisation code structures et variables

This commit is contained in:
Hugo LAMY
2022-01-22 19:16:23 +01:00
parent 3ba76ccc4e
commit cb615cb6b3
7 changed files with 173 additions and 28 deletions

View File

@@ -7,8 +7,8 @@ void print_message(t_philo *philo, char *msg)
char *color;
gettimeofday(&stime, NULL);
time_stamp = (stime.tv_sec - philo->params->t_start_s) * 1000;
time_stamp += (stime.tv_usec - philo->params->t_start_u) / 1000;
time_stamp = (stime.tv_sec - philo->global->t_start_s) * 1000;
time_stamp += (stime.tv_usec - philo->global->t_start_u) / 1000;
color = WHITE;
if (ft_strnstr(msg, "eating", ft_strlen(msg)))
color = B_YELLOW;
@@ -16,7 +16,7 @@ void print_message(t_philo *philo, char *msg)
color = B_BLUE;
else if (ft_strnstr(msg, "thinking", ft_strlen(msg)))
color = B_GREEN;
pthread_mutex_lock(philo->m_print);
pthread_mutex_lock(&(philo->global->m_print));
ft_printf("%s%i %i %s%s\n", color, time_stamp, philo->p_nbr, msg, RESET);
pthread_mutex_unlock(philo->m_print);
pthread_mutex_unlock(&(philo->global->m_print));
}