Make odd-numbered philos start 1 ms later
authorLukas Jiriste <ljiriste@student.42prague.com>
Thu, 26 Sep 2024 08:44:04 +0000 (10:44 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Thu, 26 Sep 2024 08:44:04 +0000 (10:44 +0200)
This is done for even number of philos to behave orderly.
I am no sure whether this counts as interphilo communication though...

philo/philo.c

index b8541c82c5fd6b3a1158102dbb36ed767ff9c23a..f0f52fcb7150ae3281548c5d9d01c0d9821b766a 100644 (file)
@@ -82,6 +82,8 @@ void  *be_a_philosopher(void *void_philo)
 {
        t_philo *const  philo = void_philo;
 
+       if (philo->id % 2)
+               usleep(1000);
        while (!end(philo->settings))
        {
                philo_think(philo);