Premium Only Content
Deadlocks and the Dining Philosophers Problem
In this video we will cover the “Dining Philosophers” problem.
The “Dining Philosophers” problem is an example problem to demonstrate concurrent algorithm design.
A group of philosophers sit around a table and alternate between thinking and eating using the forks on their left and right. The forks represent a shared resource between the pair of philosophers on either side of them. Philosophers need both forks to eat and only one philosopher can use a fork at a time.
If the philosophers were to simply take forks as they needed them a situation could occur where a circle of philosophers are each holding one fork and waiting on another philosopher to give up a fork. This is referred to as a “deadlock”.
A simple solution to this problem is to add a waiter, who represents a lock, that the philosophers need exclusive access to before picking up either of their forks. Once a philosopher has exclusive access to the waiter’s attention they have that attention until the philosopher has successfully picked up both forks. When a philosopher has exclusive access to the waiter they will succeed in picking up their forks either because both forks are available, and no other philosophers have the waiter's attention, or they will wait with the waiter’s attention for the philosophers on either side of them to give up their forks.
This solution of using a central arbitrator to manage access prevents a circular cycle of philosophers holding one fork while waiting on another philosopher for their other fork that causes a deadlock. This solution is fair because all of the philosophers have equal access to the waiter. However, it can be inefficient because philosophers have to wait for the waiter even when both of their forks are available.
Reference:
Dining philosophers image: bdesham - https://commons.wikimedia.org/wiki/File:An_illustration_of_the_dining_philosophers_problem.png
-
48:10
State of the Second Podcast
19 hours agoThe Quietest Suppressor Ever? PTR’s PIP Tech Explained (ft. PTR)
43 -
23:10
Demons Row
11 hours agoBiker Secrets They Never Say Out Loud (Real MC Rules Exposed)
852 -
LIVE
BEK TV
22 hours agoTrent Loos in the Morning - 12/18/2025
264 watching -
15:25
unclemattscookerylessons
1 day ago $0.27 earned“Crispy Cheesy Potato Croquettes | Gooey Mozzarella Inside!”
2903 -
6:39
DropItLikeItsScott
19 hours agoDid BURRIS Just Create the Coolest 3-12x42 Scope?
44 -
10:55
Paul Joseph Watson
1 day agoWhat Really Happened at Bondi Beach?
32.3K102 -
2:00:58
MG Show
19 hours agoFBI’s CRIMINAL RAID on Mar-a-Lago Confirmed; Rob Reiner BEHIND Russia Collusion?
20.1K14 -
1:00:18
Dialogue works
2 days ago $6.68 earnedLarry C. Johnson: Russia Launches Largest Missile & Drone Attack Yet
18.1K7 -
12:02
Actual Justice Warrior
1 day agoChicago Mayor Says ONLY Black Businesses Get Licensed
18.5K28 -
4:21
SethDrums
4 days ago50 Cent - In Da Club if it was 1950s
18.1K3