Make philos drop a fork when the other is taken
authorLukas Jiriste <ljiriste@student.42prague.com>
Thu, 26 Sep 2024 08:09:49 +0000 (10:09 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Thu, 26 Sep 2024 08:09:49 +0000 (10:09 +0200)
commit74e28ef83f4e1dcd08e66fba4f618b703ccb178e
tree9685175b0c51dde7fb9ad4ce127dbb317fff244d
parent10e39e7aa60bc5277e257ebd1f737b825a9917ff
Make philos drop a fork when the other is taken

Instead of making a fork a mutex, it now holds its state - whether it is
taken. This makes it possible for a philo to check, whether he can grab
both forks and if they cannot, they won't hold any fork.
I thought about approach before but my mind was locked onto using the
function pthread_mutex_trylock which is not permitted by the subject.
philo/mem_management.c
philo/mutex.c
philo/philo.c
philo/philo.h