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.

65 lines
1.6 KiB

3 years ago
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* philo.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/16 14:03:01 by narnaud #+# #+# */
3 years ago
/* Updated: 2022/05/20 10:38:02 by narnaud ### ########.fr */
3 years ago
/* */
/* ************************************************************************** */
3 years ago
#ifndef PHILO_H
# define PHILO_H
3 years ago
# 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;
3 years ago
typedef struct s_philo
3 years ago
{
int id;
int meals_done;
3 years ago
int last_meal_time;
t_table *table;
} t_philo;
typedef struct s_table
{
int param[5];
int i;
3 years ago
sem_t *sptr;
3 years ago
sem_t *death;
3 years ago
t_philo *philos;
3 years ago
int time;
int *pid;
3 years ago
} t_table;
3 years ago
/***************************/
t_table *parsing(char **argv);
int gettime(void);
#endif