aboutsummaryrefslogtreecommitdiff
path: root/philo_three/src/event.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_three/src/event.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_three/src/event.c')
-rw-r--r--philo_three/src/event.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/philo_three/src/event.c b/philo_three/src/event.c
index 1c7fa14..a7b6d2a 100644
--- a/philo_three/src/event.c
+++ b/philo_three/src/event.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 21:37:50 by cacharle #+# #+# */
-/* Updated: 2021/01/08 20:25:44 by charles ### ########.fr */
+/* Updated: 2021/01/09 15:48:12 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -51,17 +51,8 @@ void event_sleep(t_philo *philo)
void event_die(t_philo *philo)
{
- long int i;
-
sem_wait(philo->sem_stdout);
philo_put(philo->id, EVENT_DIE, philo->initial_time);
philo_put_flush();
- if (philo->conf->meal_num == -1)
- sem_post(philo->sem_finish);
- else
- {
- i = -1;
- while (++i < philo->conf->philo_num)
- sem_post(philo->sem_finish);
- }
+ sem_post(philo->sem_finish);
}