diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-12-30 14:06:17 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-12-30 14:06:17 +0100 |
| commit | cf2ef2c3901f3da524079a9ad912dfb99e115a7e (patch) | |
| tree | 7868f1f02a3fab1aa74606c1f9a3a00c0287976f /philo_one/src/event.c | |
| parent | 2baa67fd7ad31fe53ab21d257a104478e787fb62 (diff) | |
| download | philosophers-cf2ef2c3901f3da524079a9ad912dfb99e115a7e.tar.gz philosophers-cf2ef2c3901f3da524079a9ad912dfb99e115a7e.tar.bz2 philosophers-cf2ef2c3901f3da524079a9ad912dfb99e115a7e.zip | |
Fixed meal_num args for philo_one
Diffstat (limited to 'philo_one/src/event.c')
| -rw-r--r-- | philo_one/src/event.c | 21 |
1 files changed, 7 insertions, 14 deletions
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 <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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) |
