Change the order of waiting for term and checking
authorLukas Jiriste <ljiriste@student.42prague.com>
Thu, 30 May 2024 13:00:56 +0000 (15:00 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Thu, 30 May 2024 13:00:56 +0000 (15:00 +0200)
commit82c1d6bc9558b2845c8e5e7e1561209b8b56f31d
tree57b55eb236e2e8bc1e814787cfbf815210a37ddc
parent79ba79ea49cd92cc85ba5dd709090ecb7521aacf
Change the order of waiting for term and checking

This is done so that a philosopher truly cannot write to terminal after
it dies. Before this commit, a philosopher that is alive would wait for
term semaphore. Meanwhile something could change his state to not alive
but he could then get the semaphore and print anyway.

I thought about having the condition inside as well as on the outside
of the sem_wait. But having it just after the sem_wait should be
alright.
philo_bonus/helpers.c