42_Philosopher/philo/philo.h

37 lines
1.3 KiB
C
Raw Permalink Normal View History

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:50:01 -04:00
/* Updated: 2023/04/25 16:41:14 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
{
2023-04-25 10:50:01 -04:00
size_t id;
2023-04-25 10:31:12 -04:00
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