Upload
ramasubbu-p
View
1.482
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Presentation
Citation preview
Dining-Philosophers Problem
Dining-Philosophers Problem The philosophers share a circular table
surrounded by five chairs, each belonging to one philosopher
In the center of table is a bowl of rice, and the table is laid with 5 single chopsticks
From time to time, a philosopher gets hungry and tries to pick up the two chopsticks that are closest to her
When a hungry philosopher has both her chopsticks at the same time, she eats without releasing her chopsticks
When she is finished eating, she puts down both her chopsticks and starts thinking
Dining-Philosophers Problem
Dining-Philosophers Problem
Dining-Philosophers Problem
Methods to avoid deadlock: Allow at most four philosophers to
be sitting simultaneously Allow a philosopher to pick up her
chopsticks only if both chopsticks are available (pick them up is a critical section)
Problems with Semaphores
signal (mutex) //violate mutual exclusive critical sectionwait (mutex)
wait (mutex) //deadlock occurs critical sectionwait (mutex)
Omitting of wait (mutex) or signal (mutex) (or both)
Solution to Dining Philosophers
Solution to Dining Philosophers
Solution to Dining Philosophers
Each philosopher I invokes the operations pickup() and putdown() in the following sequence:
dp.pickup(i) EATdp.putdown(i)