Add missing index increment, change cleanup order
authorLukas Jiriste <ljiriste@student.42prague.com>
Thu, 9 May 2024 09:19:16 +0000 (11:19 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Thu, 9 May 2024 09:19:16 +0000 (11:19 +0200)
commita4c72f1bc98b22975c5eeefc9ebcd74658e0616d
tree06c4ae4f301d1b37062d9b26d0f02c6b1931a28a
parentf1ace76e8973d7d788a2da2e2cdc97ca915bcb51
Add missing index increment, change cleanup order

The program only checked the forst philo for starvation.

The change in the cleanup order is needed because without the change
(forks) mutexes were deinitialized before joining the (philo) threads.
This could lead to a philo waiting for a fork, which has just been
cleared, leading to undefined behavior (endless wait). When the main
thread joins all the threads it gets gets stuck in the one waitin for
a fork.
philo/main.c
philo/mem_management.c