diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2021-01-08 17:57:23 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2021-01-08 17:57:23 +0100 |
| commit | 36c5e3a81de8b910bc04a37994b53296c1540353 (patch) | |
| tree | ed8ff37d914606ba3b4d6921956bd9b29cac0f17 /philo_three/src/event.c | |
| parent | ad7ed73c124c8fcda6629350307f0f4f41b87fe3 (diff) | |
| download | philosophers-36c5e3a81de8b910bc04a37994b53296c1540353.tar.gz philosophers-36c5e3a81de8b910bc04a37994b53296c1540353.tar.bz2 philosophers-36c5e3a81de8b910bc04a37994b53296c1540353.zip | |
Added separate thread to flush buffer in philo_one and philo_two
Diffstat (limited to 'philo_three/src/event.c')
| -rw-r--r-- | philo_three/src/event.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/philo_three/src/event.c b/philo_three/src/event.c index 665f260..2a4ccf7 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/04 10:57:35 by cacharle ### ########.fr */ +/* Updated: 2021/01/08 15:13:02 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,6 +19,7 @@ void event_take_fork(t_philo *philo) sem_wait(philo->sem_stdout); philo_put(philo->id, EVENT_FORK, philo->initial_time); philo_put(philo->id, EVENT_FORK, philo->initial_time); + philo_put_flush(); sem_post(philo->sem_stdout); } @@ -26,6 +27,7 @@ void event_eat(t_philo *philo) { sem_wait(philo->sem_stdout); philo_put(philo->id, EVENT_EAT, philo->initial_time); + philo_put_flush(); sem_post(philo->sem_stdout); h_sleep(philo->conf->timeout_eat); } @@ -34,6 +36,7 @@ void event_think(t_philo *philo) { sem_wait(philo->sem_stdout); philo_put(philo->id, EVENT_THINK, philo->initial_time); + philo_put_flush(); sem_post(philo->sem_stdout); } @@ -41,6 +44,7 @@ void event_sleep(t_philo *philo) { sem_wait(philo->sem_stdout); philo_put(philo->id, EVENT_SLEEP, philo->initial_time); + philo_put_flush(); sem_post(philo->sem_stdout); sem_post(philo->forks); sem_post(philo->forks); @@ -53,6 +57,7 @@ void event_die(t_philo *philo) 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 |
