aboutsummaryrefslogtreecommitdiff
path: root/philo_two/src/philo_two.h
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-09-30 08:46:00 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-09-30 08:46:00 +0200
commit608ae732eccfe50f2727823f9aebe1f32681edfb (patch)
tree01d62708d1c4b0aa444e272c7f19022b5cd70821 /philo_two/src/philo_two.h
parent42360f381cebd6376c261b16038a7f12971f925e (diff)
downloadphilosophers-608ae732eccfe50f2727823f9aebe1f32681edfb.tar.gz
philosophers-608ae732eccfe50f2727823f9aebe1f32681edfb.tar.bz2
philosophers-608ae732eccfe50f2727823f9aebe1f32681edfb.zip
Refactoring philo_two to work with new common lib (not working)
Diffstat (limited to 'philo_two/src/philo_two.h')
-rw-r--r--philo_two/src/philo_two.h28
1 files changed, 22 insertions, 6 deletions
diff --git a/philo_two/src/philo_two.h b/philo_two/src/philo_two.h
index fb42628..5318510 100644
--- a/philo_two/src/philo_two.h
+++ b/philo_two/src/philo_two.h
@@ -6,21 +6,36 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 22:47:23 by cacharle #+# #+# */
-/* Updated: 2020/09/29 15:21:32 by cacharle ### ########.fr */
+/* Updated: 2020/09/30 08:41:15 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PHILO_TWO_H
# define PHILO_TWO_H
+# include <unistd.h>
+# include <stdbool.h>
# include <pthread.h>
# include <semaphore.h>
-// # include "common.h"
+
+# include "common.h"
+
+typedef struct
+{
+ long int philo_num;
+ t_time timeout_death;
+ t_time timeout_eat;
+ t_time timeout_sleep;
+ long int meal_num;
+ bool all_alive;
+ pthread_mutex_t mutex_all_alive;
+ pthread_mutex_t mutex_stdout;
+} t_philo_conf;
typedef struct
{
int id;
- t_philo_args *args;
+ t_philo_conf *conf;
t_time time_last_eat;
sem_t *forks;
} t_routine_arg;
@@ -29,14 +44,15 @@ typedef struct
** routine.c
*/
-void *routine_philo(void *void_arg);
-void *routine_death(void *void_arg);
-t_routine_arg *routine_args_create(t_philo_args *philo_args, sem_t *forks);
+void *routine_philo(t_routine_arg *arg);
+void *routine_death(t_routine_arg *arg);
+t_routine_arg *routine_args_create(t_philo_conf *conf, sem_t *forks);
/*
** io.c
*/
+void io_take_fork(t_routine_arg *arg);
void io_eat(t_routine_arg *arg);
void io_think(t_routine_arg *arg);
void io_sleep(t_routine_arg *arg);