Dining Philosopher - Only Locks

aaaa
Last edited on
The point of mutexes is that they protect shared resources. The only really shared resource is forks, hence you need only one mutex.

What you're doing is a bit more complicated than this:

https://en.wikipedia.org/wiki/Dining_philosophers_problem

So on line 78: I don't see the reason for usedForkLast?

I would have expected a process like this:

-> acquire mutex (WaitForSingleObject(...) in your case)
-> depending on the availability of the forks either the state remains HUNGRY or changed to EATING

case EATING -> random sleeping -> put forks back -> change state to THINKING [or TALKING] -> random sleeping
case HUNGRY -> short sleeping

-> try acquiring mutex/forks again or leaving
Topic archived. No new replies allowed.