Skip to content

A Classic Concurrency Problem illustrating the actions of Multithreads and Processes

Notifications You must be signed in to change notification settings

mdabir1203/Philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Philosophers

##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.

image

##Learning Outcomes:

  1. Threads and Processes
  2. Difference between Mutex and Semaphores
  3. Building Multithreaded applications and designing distributed systems
  4. 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

Deadlock_at_a_four-way-stop

  1. Race Conditions and Data Race

image

Live Coding Demonstration Example:

image

Output : Its different everytime. This is not thread safe . Two threads are racing or who gets first.

image

----------- Data Race ---------------

image

Detailed explanation: https://ckk.ai/datarace

  1. Helgrind (Tool to check datarace)

  2. Avoiding Resource starvation.

Sources:

1.https://ckk.ai/miro

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

About

A Classic Concurrency Problem illustrating the actions of Multithreads and Processes

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published