This is an implementation of the dining philosophers problem.
The problem is designed to illustrate the use of threads and resource sharing in a concurrent programming environment. Each philosopher is represented by a thread.
Each philosopher has two forks, and each fork is represented by a mutex. Each philosopher must acquire the two forks in order to eat. The forks are shared between the philosophers, so each philosopher must acquire the mutex associated with the fork.
Deadlock is a problem where two or more threads are blocked waiting for each other, which must be avoided. A correct solution to the dining philosophers problem is to avoid deadlock.
make
./philo [num_philosophers] [time_to_die] [time_to_eat] [time_to_sleep] [num_of_meals]
fig.1 - An illustration of the dining philosophers problem, src: wikipedia
