From 0dad3463b22e541153dcfded178eb0f3fe428cbd Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Sun, 26 Jan 2025 12:44:13 +0100 Subject: Update simulation and fix norme errors --- philo/include/philo.h | 57 +++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 27 deletions(-) (limited to 'philo/include/philo.h') diff --git a/philo/include/philo.h b/philo/include/philo.h index fbcf53f..bbc1bc2 100644 --- a/philo/include/philo.h +++ b/philo/include/philo.h @@ -6,51 +6,54 @@ /* By: dkaiser -# include -# include -# include # include "ft_utils.h" +# include +# include +# include +# include # define ERR_USAGE "Usage: [times_must_eat]" # define ERR_MALLOC "Memory allocation failed" typedef struct s_fork { - int available; - pthread_mutex_t mutex; -} t_fork; + int owner; + pthread_mutex_t mutex; +} t_fork; typedef struct s_phdata { - int nbr_of_philos; - int time_to_die; - int time_to_eat; - int time_to_sleep; - int times_must_eat; - int philos_must_eat; - pthread_mutex_t pme_mutex; - int simulation_running; - t_fork *forks; -} t_phdata; + int nbr_of_philos; + int time_to_die; + int time_to_eat; + int time_to_sleep; + int times_must_eat; + int philos_must_eat; + pthread_mutex_t pme_mutex; + int simulation_running; + t_fork *forks; +} t_phdata; typedef struct s_philo { - int id; - int last_time_eaten; - int times_must_eat; - int is_alive; - pthread_t thread; - t_phdata *data; -} t_philo; - -int run_simulation(int nbr_of_philos, t_philo *philos, t_phdata *data); + int id; + int last_time_eaten; + int times_must_eat; + int is_alive; + pthread_t thread; + t_phdata *data; +} t_philo; + +int run_simulation(int nbr_of_philos, t_philo *philos, + t_phdata *data); +int philo_die(t_philo *philo); +void philo_eat(t_philo *philo); #endif -- cgit v1.2.3