philosopher/mandatory/philo.h
2023-03-28 00:43:06 +02:00

59 lines
1.5 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* philo.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/08 14:51:16 by erey-bet #+# #+# */
/* Updated: 2023/03/27 16:55:06 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PHILO_H
# define PHILO_H
# include "../utils/utils.h"
# include <stdlib.h>
# include <unistd.h>
# include <pthread.h>
# include <sys/wait.h>
# include <sys/time.h>
# include <pthread.h>
# include <stdio.h>
typedef struct s_config
{
int nbr_philo;
long time_die;
long time_eat;
long time_sleep;
long must_eat;
} t_config;
typedef struct s_same
{
t_config *config;
pthread_mutex_t *mutex;
long long *time;
int *death;
} t_same;
typedef struct s_only
{
int *id;
} t_only;
typedef struct s_philo
{
t_same *same;
t_only *only;
} t_philo;
int parsing(char *argv[], t_config *conf);
int manage_threads(t_config *conf);
void *philosopher(t_philo *philo);
#endif