aboutsummaryrefslogtreecommitdiff
path: root/philo_one
diff options
context:
space:
mode:
Diffstat (limited to 'philo_one')
-rw-r--r--philo_one/src/event.c9
-rw-r--r--philo_one/src/philo.c9
-rw-r--r--philo_one/src/philo_one.h33
3 files changed, 30 insertions, 21 deletions
diff --git a/philo_one/src/event.c b/philo_one/src/event.c
index 8952212..5261f4c 100644
--- a/philo_one/src/event.c
+++ b/philo_one/src/event.c
@@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* io.c :+: :+: :+: */
+/* event.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 21:37:50 by cacharle #+# #+# */
-/* Updated: 2020/09/30 09:43:31 by cacharle ### ########.fr */
+/* Updated: 2020/10/05 14:27:39 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -48,7 +48,10 @@ void event_think(t_philo *arg)
pthread_mutex_unlock(&arg->conf->mutex_stdout);
}
-void event_sleep(t_philo *arg, pthread_mutex_t *fork_right, pthread_mutex_t *fork_left)
+void event_sleep(
+ t_philo *arg,
+ pthread_mutex_t *fork_right,
+ pthread_mutex_t *fork_left)
{
pthread_mutex_lock(&arg->conf->mutex_stdout);
if (!arg->conf->all_alive)
diff --git a/philo_one/src/philo.c b/philo_one/src/philo.c
index 45a8a17..6ea1024 100644
--- a/philo_one/src/philo.c
+++ b/philo_one/src/philo.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/09 23:47:14 by cacharle #+# #+# */
-/* Updated: 2020/09/30 09:48:12 by cacharle ### ########.fr */
+/* Updated: 2020/10/05 14:29:10 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -39,8 +39,11 @@ bool philos_start(t_philo *philos, int num)
i = -1;
while (++i < num)
{
- if (pthread_create(&philos[i].thread, NULL,
- (t_routine)routine_philo, (void*)(philos + i)) == -1)
+ if (pthread_create(
+ &philos[i].thread,
+ NULL,
+ (t_routine)routine_philo,
+ (void*)(philos + i)) == -1)
return (false);
}
return (true);
diff --git a/philo_one/src/philo_one.h b/philo_one/src/philo_one.h
index cb41b77..ae7d040 100644
--- a/philo_one/src/philo_one.h
+++ b/philo_one/src/philo_one.h
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/24 06:11:16 by cacharle #+# #+# */
-/* Updated: 2020/09/30 09:50:02 by cacharle ### ########.fr */
+/* Updated: 2020/10/05 14:28:24 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -30,7 +30,7 @@
typedef struct
{
long int philo_num;
- t_time timeout_death;
+ t_time timeout_death;
t_time timeout_eat;
t_time timeout_sleep;
long int meal_num;
@@ -53,33 +53,36 @@ typedef struct s_philo
** forks.c
*/
-pthread_mutex_t *forks_new(int num);
-void forks_destroy(pthread_mutex_t *forks, int num);
+pthread_mutex_t *forks_new(int num);
+void forks_destroy(pthread_mutex_t *forks, int num);
/*
** philo.c
*/
-t_philo *philos_new(t_philo_conf *conf, pthread_mutex_t *forks);
-void philos_destroy(t_philo *philos, int num);
-bool philos_start(t_philo *philos, int num);
-void philos_detach(t_philo *philos, int num);
+t_philo *philos_new(t_philo_conf *conf, pthread_mutex_t *forks);
+void philos_destroy(t_philo *philos, int num);
+bool philos_start(t_philo *philos, int num);
+void philos_detach(t_philo *philos, int num);
/*
** routine.c
*/
-void *routine_philo(t_philo *arg);
-void *routine_death(t_philo *arg);
+void *routine_philo(t_philo *arg);
+void *routine_death(t_philo *arg);
/*
** io.c
*/
-void event_take_fork(t_philo *arg, pthread_mutex_t *fork);
-void event_eat(t_philo *arg);
-void event_think(t_philo *arg);
-void event_sleep(t_philo *arg, pthread_mutex_t *fork_right, pthread_mutex_t *fork_left);
-void event_die(t_philo *arg);
+void event_take_fork(t_philo *arg, pthread_mutex_t *fork);
+void event_eat(t_philo *arg);
+void event_think(t_philo *arg);
+void event_sleep(
+ t_philo *arg,
+ pthread_mutex_t *fork_right,
+ pthread_mutex_t *fork_left);
+void event_die(t_philo *arg);
#endif