From e874ad94a31a8259b8eb7ad2865767c081bcd279 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sun, 3 Jan 2021 14:04:22 +0100 Subject: Fixing philo_one/philo_two dying by sleeping more when checking the death, Fixing timestamp in the wrong order in philo_three --- philo_two/src/event.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'philo_two/src/event.c') diff --git a/philo_two/src/event.c b/philo_two/src/event.c index 0544042..eead2f5 100644 --- a/philo_two/src/event.c +++ b/philo_two/src/event.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 21:37:50 by cacharle #+# #+# */ -/* Updated: 2021/01/02 11:25:08 by cacharle ### ########.fr */ +/* Updated: 2021/01/03 13:55:28 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,14 +16,14 @@ void event_take_fork(t_philo *arg) { sem_wait(arg->forks); sem_wait(arg->conf->sem_stdout); - philo_put(arg->id, EVENT_FORK); + philo_put(arg->id, EVENT_FORK, arg->conf->initial_time); sem_post(arg->conf->sem_stdout); } void event_eat(t_philo *arg) { sem_wait(arg->conf->sem_stdout); - philo_put(arg->id, EVENT_EAT); + philo_put(arg->id, EVENT_EAT, arg->conf->initial_time); sem_post(arg->conf->sem_stdout); usleep(arg->conf->timeout_eat * 1000); } @@ -31,14 +31,14 @@ void event_eat(t_philo *arg) void event_think(t_philo *arg) { sem_wait(arg->conf->sem_stdout); - philo_put(arg->id, EVENT_THINK); + philo_put(arg->id, EVENT_THINK, arg->conf->initial_time); sem_post(arg->conf->sem_stdout); } void event_sleep(t_philo *arg) { sem_wait(arg->conf->sem_stdout); - philo_put(arg->id, EVENT_SLEEP); + philo_put(arg->id, EVENT_SLEEP, arg->conf->initial_time); sem_post(arg->conf->sem_stdout); sem_post(arg->forks); sem_post(arg->forks); @@ -50,7 +50,7 @@ void event_die(t_philo *arg) long int i; sem_wait(arg->conf->sem_stdout); - philo_put(arg->id, EVENT_DIE); + philo_put(arg->id, EVENT_DIE, arg->conf->initial_time); if (arg->conf->meal_num == -1) sem_post(arg->conf->sem_finish); else -- cgit