fix: philo alone died now
This commit is contained in:
parent
02a80af93b
commit
69e34424c1
6
philo.c
6
philo.c
@ -42,6 +42,12 @@ bool philo_eat(t_philo *philo, t_data *data)
|
|||||||
pthread_mutex_unlock(&data->forks[philo->id]);
|
pthread_mutex_unlock(&data->forks[philo->id]);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
while ((philo->id + 1) % data->nb_philos == philo->id)
|
||||||
|
if (check(philo, data))
|
||||||
|
{
|
||||||
|
pthread_mutex_unlock(&data->forks[philo->id]);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
pthread_mutex_lock(&data->forks[(philo->id + 1) % data->nb_philos]);
|
pthread_mutex_lock(&data->forks[(philo->id + 1) % data->nb_philos]);
|
||||||
print_take_a_fork(philo);
|
print_take_a_fork(philo);
|
||||||
if (check(philo, data))
|
if (check(philo, data))
|
||||||
|
Loading…
Reference in New Issue
Block a user