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
-
27:39
MYLUNCHBREAK CHANNEL PAGE
4 hours agoDestroying Time.
82.1K5 -
2:14:31
Side Scrollers Podcast
4 hours agoSide Scrollers INVITE ONLY - Live From Dreamhack
119K7 -
1:18:23
Simply Bitcoin
2 days ago $5.03 earnedThe Bitcoin Crucible w/ Alex Stanczyk and Lawrence Lepard
8.52K4 -
1:25:03
Jeff Ahern
5 hours ago $11.90 earnedThe Saturday Show with Jeff Ahern
62.8K8 -
1:31:56
Michael Franzese
20 hours agoWill NBA do anything about their Gambling Problems?
119K26 -
57:26
X22 Report
9 hours agoMr & Mrs X - The Food Industry Is Trying To Pull A Fast One On RFK Jr (MAHA), This Will Fail - EP 14
99.5K61 -
2:01:08
LFA TV
1 day agoTHE RUMBLE RUNDOWN LIVE @9AM EST
149K12 -
1:28:14
On Call with Dr. Mary Talley Bowden
7 hours agoI came for my wife.
27.9K33 -
1:06:36
Wendy Bell Radio
12 hours agoPet Talk With The Pet Doc
66.6K32 -
30:58
SouthernbelleReacts
3 days ago $9.08 earnedWe Didn’t Expect That Ending… ‘Welcome to Derry’ S1 E1 Reaction
45.5K12