merge
This commit is contained in:
commit
531d3146e4
2
data.c
2
data.c
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
bool data_init(t_data *data)
|
bool data_init(t_data *data)
|
||||||
{
|
{
|
||||||
|
data->stop = 0;
|
||||||
data->forks = malloc(sizeof(bool) * data->nb_philos);
|
data->forks = malloc(sizeof(bool) * data->nb_philos);
|
||||||
if (data->forks == NULL)
|
if (data->forks == NULL)
|
||||||
return (1);
|
return (1);
|
||||||
@ -31,7 +32,6 @@ bool data_init(t_data *data)
|
|||||||
pthread_mutex_init(&data->forks_mutex, NULL);
|
pthread_mutex_init(&data->forks_mutex, NULL);
|
||||||
pthread_mutex_init(&data->stop_mutex, NULL);
|
pthread_mutex_init(&data->stop_mutex, NULL);
|
||||||
pthread_mutex_init(&data->print_mutex, NULL);
|
pthread_mutex_init(&data->print_mutex, NULL);
|
||||||
data->stop = 0;
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
philo.c
2
philo.c
@ -146,7 +146,9 @@ t_philo *philo_init(t_data *data)
|
|||||||
philo->id = id++;
|
philo->id = id++;
|
||||||
philo->data = data;
|
philo->data = data;
|
||||||
philo->nb_meal = 0;
|
philo->nb_meal = 0;
|
||||||
|
philo->stop = 0;
|
||||||
philo->last_eat = get_time();
|
philo->last_eat = get_time();
|
||||||
|
philo->last_sleep = get_time();
|
||||||
pthread_mutex_init(&philo->nb_meal_mutex, NULL);
|
pthread_mutex_init(&philo->nb_meal_mutex, NULL);
|
||||||
pthread_mutex_init(&philo->last_eat_mutex, NULL);
|
pthread_mutex_init(&philo->last_eat_mutex, NULL);
|
||||||
pthread_mutex_init(&philo->last_sleep_mutex, NULL);
|
pthread_mutex_init(&philo->last_sleep_mutex, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user