From 9d8665eaa18f9d8b77faa09b4b9a2e21f583a640 Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Tue, 19 Mar 2024 14:41:48 +0100 Subject: [PATCH] Make a loop in check_death less busy This change makes the main thread sleep for the time it would take the "most hungry" philosopher to die. It is thus guaranteed that no philosopher may die during the sleep. --- philo/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/philo/main.c b/philo/main.c index 5141588..3551938 100644 --- a/philo/main.c +++ b/philo/main.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/05 12:49:40 by ljiriste #+# #+# */ -/* Updated: 2024/03/19 14:26:42 by ljiriste ### ########.fr */ +/* Updated: 2024/03/19 14:39:29 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -326,7 +326,7 @@ void check_death(t_philo *philos, t_settings *set) return ; } now = cur_time_sus(); - //usleep(now - oldest); + usleep(set->time_to_die - (now - oldest)); } } -- 2.30.2