Dining Philosophers Problem Solution Report
This report describes the approach taken to solve the Dining Philosophers Problem, a well-
known computer science puzzle that highlights concurrency and synchronization issues.
The puzzle represents a group of philosophers sitting around a table, sharing chopsticks
while they alternate between eating and thinking.
Each philosopher is represented by a different thread in this implementation. Mutexes are
used to handle chopsticks to prevent deadlock and guarantee that no two philosophers can
use the same chopstick at the same time. To avoid deadlock, philosophers try to pick up
their left and right chopsticks in a particular order based on their ID.
Two distribution approaches are used to produce random values for the philosophers'
pondering and meal durations: exponential and uniform. Whereas the exponential
distribution chooses durations based on a mean value, the uniform distribution chooses
random durations equally within a given range. This durational unpredictability mimics the
capricious character of philosophers' activities.
The amount of time that each philosopher waits for both chopsticks or their hunger state, is
measured exactly. The philosopher's attempt to pick up their first chopstick is the beginning
of this measurement, which concludes when they have successfully picked up their second.
These times are recorded for every meal that any philosopher consumes.
The program determines the average and standard deviation of all hungry state durations
once every philosopher has finished their meal. The standard deviation shows the variation
in these waiting times, while the average hungry time gives an idea of the average waiting
time for philosophers.