From: Lukas Jiriste Date: Tue, 19 Mar 2024 13:41:48 +0000 (+0100) Subject: Make a loop in check_death less busy X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=9d8665eaa18f9d8b77faa09b4b9a2e21f583a640;p=42%2Fphilosophers_old.git 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. --- 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)); } }