42 lines
671 B
C
42 lines
671 B
C
#ifndef PHILO_STRUCT_H
|
|
# define PHILO_STRUCT_H
|
|
|
|
typedef pthread_mutex_t t_mtx;
|
|
|
|
typedef struct s_time
|
|
{
|
|
long int ts;
|
|
long int tu;
|
|
} t_time;
|
|
|
|
typedef struct s_params
|
|
{
|
|
int n_phi; // number_of_philosophers
|
|
int t_die; // time_to_die
|
|
int t_eat; // time_to_eat
|
|
int t_slp; // time_to_sleep
|
|
int n_eat; // [number_of_times_each_philosopher_must_eat]
|
|
} t_params;
|
|
|
|
typedef struct s_global
|
|
{
|
|
int dead;
|
|
int n_eat;
|
|
t_time t_start;
|
|
t_mtx m_print;
|
|
t_mtx m_dead;
|
|
} t_global;
|
|
|
|
typedef struct s_philo
|
|
{
|
|
t_params *params;
|
|
t_global *global;
|
|
int p_nbr;
|
|
t_mtx m_fork;
|
|
t_time t_last_meal;
|
|
int eat;
|
|
struct s_philo *next;
|
|
} t_philo;
|
|
|
|
#endif
|