##The Dining Philosophers problem is a classic concurrency problem that illustrates the challenges of coordinating the actions of multiple threads or processes that share a common resource.
##Learning Outcomes:
- Threads and Processes
- Difference between Mutex and Semaphores
- Building Multithreaded applications and designing distributed systems
- Avoiding Deadlocks(So all don't eat at the same time)
-->> a process or thread enters a waiting state because a requested system resource is held by another waiting process, which in turn is waiting for another resource held by another waiting process
**Mutual Exclusions **Hold and Wait **No Preemptions **Circular Wait
- Race Conditions and Data Race
Live Coding Demonstration Example:
Output : Its different everytime. This is not thread safe . Two threads are racing or who gets first.----------- Data Race ---------------
Detailed explanation: https://ckk.ai/datarace
-
Helgrind (Tool to check datarace)
-
Avoiding Resource starvation.
Sources:
2.https://en.wikipedia.org/wiki/Dining_philosophers_problem 3.