Fix the hunger_watcher loop
authorLukas Jiriste <ljiriste@student.42prague.com>
Tue, 28 May 2024 12:25:28 +0000 (14:25 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Tue, 28 May 2024 12:25:28 +0000 (14:25 +0200)
The hunger_watcher should exit its loop when philo has no time left.

philo_bonus/hunger_watcher.c

index 254dfd815b13a0a14e04c1ce32f3d613d935e337..03edef835e6b56749498977f16db8e3e38ffb01e 100644 (file)
@@ -36,7 +36,7 @@ static void   *watch_for_starvation(void *philo_void)
        philo = philo_void;
        sem_wait(philo->philo_sem);
        time = time_till_death(philo);
-       while (time == 0)
+       while (time > 0)
        {
                sem_post(philo->philo_sem);
                usleep(time / 2);