From 10e39e7aa60bc5277e257ebd1f737b825a9917ff Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Thu, 5 Sep 2024 11:43:59 +0200 Subject: [PATCH] Make the sleep between death check be max 100 us This is implemented so that main checks well fed condition more frequently. Without the well fed condition can be satisfied for a long time before main notices, particularly for long time_to_death. --- philo/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/philo/main.c b/philo/main.c index 2e75583..c736ff6 100644 --- a/philo/main.c +++ b/philo/main.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/22 11:19:48 by ljiriste #+# #+# */ -/* Updated: 2024/09/05 11:32:29 by ljiriste ### ########.fr */ +/* Updated: 2024/09/05 11:43:30 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -108,7 +108,8 @@ static enum e_end watch_philosophers(t_diner *diner) mutex_unlock(&diner->setting.end_lock); return (well_fed); } - usleep(closest_death_time - usecs_since_start(diner->setting.start)); + if (closest_death_time - usecs_since_start(diner->setting.start) > 100) + usleep(100); } } -- 2.30.2