#include "philo.h" void *philo_exec(void *arg) { t_philo *philo; int nbr; philo = (t_philo*)arg; nbr = philo->philo_nbr; // eat // "has taken a fork" // "is eating" // sleep // "is sleeping" // think // "is thinking" // die // "died" int i = 0; while (i < 2) { pthread_mutex_lock(&mutex); if (philo->fork == 1 && philo->next->fork == 1) { philo->fork = 0; philo->next->fork = 0; ft_putnbr_fd(philo->philo_nbr, 1); ft_putstr_fd(" has taken a fork\n", 1); } pthread_mutex_unlock(&mutex); usleep(philo->conditions->t_eat); pthread_mutex_lock(&mutex); philo->fork = 1; philo->next->fork = 1; ft_printf("%i is sleeping\n", philo->philo_nbr); pthread_mutex_unlock(&mutex); usleep(philo->conditions->t_slp); i++; } return (NULL); }