This commit is contained in:
Camille Chauvet 2023-05-25 15:24:35 +02:00
parent 61b599b9f2
commit 984f4c59bf

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/27 11:44:14 by cchauvet #+# #+# */
/* Updated: 2023/05/24 14:03:42 by cchauvet ### ########.fr */
/* Updated: 2023/05/25 15:08:44 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,13 +16,6 @@
#include "./print.h"
#include "data.h"
void philo_stop(t_philo *philo)
{
pthread_mutex_lock(&philo->stop_mutex);
philo->stop = 1;
pthread_mutex_unlock(&philo->stop_mutex);
}
bool check(t_philo *philo, t_data *data)
{
bool stop;
@ -106,12 +99,14 @@ void *philo_routine(void *arg)
while (true)
{
if (check(philo, data)
|| philo_eat(philo, data)
|| check(philo, data)
|| philo_sleep(data, philo)
|| check(philo, data))
|| philo_eat(philo, data)
|| check(philo, data)
|| philo_sleep(data, philo)
|| check(philo, data))
{
philo_stop(philo);
pthread_mutex_lock(&philo->stop_mutex);
philo->stop = 1;
pthread_mutex_unlock(&philo->stop_mutex);
return (NULL);
}
print_thinking(philo);