2023-04-13 09:00:39 -04:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* */
|
|
|
|
/* ::: :::::::: */
|
|
|
|
/* philo.h :+: :+: :+: */
|
|
|
|
/* +:+ +:+ +:+ */
|
|
|
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
|
|
|
/* +#+#+#+#+#+ +#+ */
|
|
|
|
/* Created: 2023/03/08 14:38:14 by cchauvet #+# #+# */
|
2023-04-25 10:31:12 -04:00
|
|
|
/* Updated: 2023/04/25 14:05:15 by cchauvet ### ########.fr */
|
2023-04-13 09:00:39 -04:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
2023-04-25 10:31:12 -04:00
|
|
|
#ifndef PHILO_H
|
|
|
|
# define PHILO_H
|
|
|
|
# include <pthread.h>
|
2023-04-13 09:00:39 -04:00
|
|
|
# include <stdio.h>
|
|
|
|
# include <stdbool.h>
|
|
|
|
# include <stdlib.h>
|
|
|
|
# include "./data.h"
|
|
|
|
|
2023-04-25 10:31:12 -04:00
|
|
|
typedef struct s_philo
|
|
|
|
{
|
|
|
|
size_t id;
|
|
|
|
pthread_mutex_t nb_meal_mutex;
|
|
|
|
size_t nb_meal;
|
|
|
|
pthread_mutex_t last_eat_mutex;
|
|
|
|
size_t last_eat;
|
|
|
|
pthread_mutex_t stop_mutex;
|
|
|
|
bool stop;
|
|
|
|
t_data *data;
|
|
|
|
} t_philo;
|
|
|
|
|
2023-04-13 09:00:39 -04:00
|
|
|
t_philo *philo_init(t_data *data);
|
|
|
|
void philo_destroyer(t_philo *philo);
|
|
|
|
void *philo_routine(void *arg);
|
2023-04-25 10:31:12 -04:00
|
|
|
#endif
|