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
-
LIVE
Scottish Viking Gaming
3 hours ago💚Rumble :|: SUNDAY FUNDAY :|: Virginia has two Verginers, Change my Mind!
820 watching -
1:49:50
Winston Marshall
2 days agoThe DARK Reality of Socialism - Historian Giles Udy
14.1K35 -
DVR
Sports Wars
2 hours agoBengals STAY ALIVE In OT Thriller, ESPN's Ryan Clark SLAMMED, NFL DESTROYS NBA On Christmas
8.31K1 -
9:37
EvenOut
19 hours ago $1.83 earnedThe Non-Reflecting Mirror Scare Twin Prank!
13.3K1 -
11:19
Tundra Tactical
18 hours ago $2.25 earnedI Saw How CMMG Makes Guns.
15.9K6 -
15:34
Misha Petrov
14 hours agoReacting To TikTok’s Most DELUSIONAL Takes!
18.1K17 -
1:52:24
Squaring The Circle, A Randall Carlson Podcast
1 day ago#032 Flournoy Holmes' Artwork Helped Define The Southern Rock Phenomenon of The Early 1970's
15.6K3 -
19:56
inspirePlay
1 day ago $0.21 earnedWalking with Lions & Facing Africa’s Wild Side | Safari Adventure with the Grid Championship Crew!
8.97K1 -
10:50
RTT: Guns & Gear
1 day ago $0.72 earnedBudget Friendly Carry 2011: EAA Girsan Brat 2311
10.6K3 -
3:49:06
Alex Zedra
16 hours agoLIVE! New Game | Nuclear Nightmare
102K13