This commit is contained in:
Camille Chauvet 2023-04-25 11:30:55 +00:00
commit 531d3146e4
2 changed files with 3 additions and 1 deletions

2
data.c
View File

@ -11,6 +11,7 @@
bool data_init(t_data *data)
{
data->stop = 0;
data->forks = malloc(sizeof(bool) * data->nb_philos);
if (data->forks == NULL)
return (1);
@ -31,7 +32,6 @@ bool data_init(t_data *data)
pthread_mutex_init(&data->forks_mutex, NULL);
pthread_mutex_init(&data->stop_mutex, NULL);
pthread_mutex_init(&data->print_mutex, NULL);
data->stop = 0;
return (0);
}

View File

@ -146,7 +146,9 @@ t_philo *philo_init(t_data *data)
philo->id = id++;
philo->data = data;
philo->nb_meal = 0;
philo->stop = 0;
philo->last_eat = get_time();
philo->last_sleep = get_time();
pthread_mutex_init(&philo->nb_meal_mutex, NULL);
pthread_mutex_init(&philo->last_eat_mutex, NULL);
pthread_mutex_init(&philo->last_sleep_mutex, NULL);