From: Lukas Jiriste Date: Thu, 5 Sep 2024 09:43:59 +0000 (+0200) Subject: Make the sleep between death check be max 100 us X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=10e39e7aa60bc5277e257ebd1f737b825a9917ff;p=42%2Fphilosophers.git 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. --- 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); } }