aboutsummaryrefslogtreecommitdiff
path: root/philo_two/src/routine.c
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2021-01-09 16:07:01 +0100
committerCharles Cabergs <me@cacharle.xyz>2021-01-09 16:07:01 +0100
commit802ea8347d1ceb7a02cf279359b3b101106fab94 (patch)
tree3f8b38056e29d94a813351fb99cc911d89f8df3d /philo_two/src/routine.c
parentebbd81e4312d945b359d2761acfeb613da1f98c8 (diff)
downloadphilosophers-802ea8347d1ceb7a02cf279359b3b101106fab94.tar.gz
philosophers-802ea8347d1ceb7a02cf279359b3b101106fab94.tar.bz2
philosophers-802ea8347d1ceb7a02cf279359b3b101106fab94.zip
Added separate thread to check if max meal num is reached independent from philosopher death
Diffstat (limited to 'philo_two/src/routine.c')
-rw-r--r--philo_two/src/routine.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/philo_two/src/routine.c b/philo_two/src/routine.c
index 52bf53d..c491a0a 100644
--- a/philo_two/src/routine.c
+++ b/philo_two/src/routine.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 23:00:07 by cacharle #+# #+# */
-/* Updated: 2021/01/08 20:18:00 by charles ### ########.fr */
+/* Updated: 2021/01/09 15:17:32 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -33,7 +33,7 @@ void *routine_philo(t_philo *arg)
if (arg->conf->meal_num != -1 && ++eat_counter == arg->conf->meal_num)
{
sem_wait(arg->conf->sem_stdout);
- sem_post(arg->conf->sem_finish);
+ sem_post(arg->conf->sem_meal_num);
sem_post(arg->conf->sem_stdout);
}
event_sleep(arg);
@@ -57,7 +57,7 @@ void *routine_death(t_philo *arg)
return (NULL);
}
-t_philo *routine_create_philos(t_philo_conf *conf, sem_t *forks)
+t_philo *routine_create_philos(t_philo_conf *conf)
{
int i;
t_philo *philos;
@@ -68,7 +68,6 @@ t_philo *routine_create_philos(t_philo_conf *conf, sem_t *forks)
while (++i < conf->philo_num)
{
philos[i].id = i + 1;
- philos[i].forks = forks;
philos[i].conf = conf;
}
return (philos);