From cf2ef2c3901f3da524079a9ad912dfb99e115a7e Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Wed, 30 Dec 2020 14:06:17 +0100 Subject: Fixed meal_num args for philo_one --- philo_one/src/event.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'philo_one/src/event.c') diff --git a/philo_one/src/event.c b/philo_one/src/event.c index 5261f4c..ef3d7a5 100644 --- a/philo_one/src/event.c +++ b/philo_one/src/event.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 21:37:50 by cacharle #+# #+# */ -/* Updated: 2020/10/05 14:27:39 by cacharle ### ########.fr */ +/* Updated: 2020/12/30 13:39:56 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,19 +24,12 @@ void event_take_fork(t_philo *arg, pthread_mutex_t *fork) void event_eat(t_philo *arg) { - int eat_counter; - - eat_counter = 0; - while (eat_counter < arg->conf->meal_num) - { - pthread_mutex_lock(&arg->conf->mutex_stdout); - if (!arg->conf->all_alive) - return ; - philo_put(arg->id, EVENT_EAT); - pthread_mutex_unlock(&arg->conf->mutex_stdout); - usleep(arg->conf->timeout_eat * 1000); - eat_counter++; - } + pthread_mutex_lock(&arg->conf->mutex_stdout); + if (!arg->conf->all_alive) + return ; + philo_put(arg->id, EVENT_EAT); + pthread_mutex_unlock(&arg->conf->mutex_stdout); + usleep(arg->conf->timeout_eat * 1000); } void event_think(t_philo *arg) -- cgit