-
Notifications
You must be signed in to change notification settings - Fork 0
/
philosophers.h
56 lines (50 loc) · 1.77 KB
/
philosophers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* philosophers.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tnamir <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/01 18:49:35 by tnamir #+# #+# */
/* Updated: 2022/03/10 18:53:10 by tnamir ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PHILOSOPHERS_H
# define PHILOSOPHERS_H
# include <unistd.h>
# include <stdio.h>
# include <pthread.h>
# include <stdlib.h>
# include <sys/time.h>
typedef struct s_info
{
long start;
int philo_id;
unsigned int time_to_die;
unsigned int time_to_eat;
unsigned int time_to_sleep;
int nbr_of_times_philo_eat;
long death_time_reset;
int *philo_nbr;
int *state;
pthread_mutex_t *left_fork;
pthread_mutex_t *right_fork;
} t_info;
typedef struct s_philo
{
int death_checker;
int philo_nbr;
int nbr_of_forks;
int state;
t_info *info;
pthread_mutex_t *forks;
} t_philo;
int ft_atoi(const char *str);
void initializer(int c, char **v, t_philo *philo, int x);
int eating(t_info *info, int *one_time_wait);
int sleeping(t_info *info);
int thinking(t_info *info);
long long current_time(void);
void *death(void *info);
void ultra_sleep(long long sleeptime);
#endif