42 school project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

64 lines
1.6 KiB

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* philo.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/16 14:03:01 by narnaud #+# #+# */
/* Updated: 2022/05/20 10:38:02 by narnaud ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PHILO_H
# define PHILO_H
# include <unistd.h>
# include <stdio.h>
# include <stdlib.h>
# include <pthread.h>
# include <string.h>
# include <errno.h>
# include <fcntl.h>
# include <signal.h>
# include <sys/wait.h>
# include <sys/time.h>
# include <sys/stat.h>
# include <semaphore.h>
enum e_params
{
PHILO_AMOUNT,
DIE_TIME,
EAT_DURATION,
SLEEP_DURATION,
MEALS_AMOUNT,
};
typedef struct s_table t_table;
typedef struct s_philo
{
int id;
int meals_done;
int last_meal_time;
t_table *table;
} t_philo;
typedef struct s_table
{
int param[5];
int i;
sem_t *sptr;
sem_t *death;
t_philo *philos;
int time;
int *pid;
} t_table;
/***************************/
t_table *parsing(char **argv);
int gettime(void);
#endif