From 7e971b3fa805c40d02ac3e996ab1d181f9584866 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sun, 3 Jan 2021 16:58:00 +0100 Subject: Added h_sleep instead of usleep for better precision --- philo_one/src/routine.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'philo_one/src/routine.c') diff --git a/philo_one/src/routine.c b/philo_one/src/routine.c index 70e6694..d8291ef 100644 --- a/philo_one/src/routine.c +++ b/philo_one/src/routine.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/10 01:11:27 by cacharle #+# #+# */ -/* Updated: 2021/01/03 12:23:35 by cacharle ### ########.fr */ +/* Updated: 2021/01/03 16:42:36 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -59,15 +59,9 @@ void *routine_philo(t_philo *arg) void *routine_death(t_philo *arg) { - t_time current; - - current = h_time_now(); while (!philo_finished(arg->conf) && - current - arg->time_last_eat < arg->conf->timeout_death) - { - current = h_time_now(); - usleep(1000); - } + h_time_now() - arg->time_last_eat < arg->conf->timeout_death) + usleep(500); event_die(arg); return (NULL); } -- cgit