deadlock

来源:百度知道 编辑:UC知道 时间:2024/09/28 15:00:32
In a dining room, a group of lecturers have worked up a solution to avoid deadlock. Before eating, each lecturer will flip a coin to decide whether to pick up the left fork or the right fork first. If the second fork is taken, the lecturer will put first fork down, and then flip the coin again.

a)Is this solution ‘deadlock free’?

b)Does it guarantee that the lecturers will not starve and why?

c)Modify the solution as necessary to guarantee freedom from deadlock and starvation.

a)Yes
b) No, this doesn’t ensure the lecturers not starve. Assume there are only 12 pairs of fork (left and right is count as one pair), when instantly 12 right fork had been taken by the lectures and the following lectures who want using the right fork will have to wait and now’s the starvation will occur.
c) The solution given should be remain but prepare equal number pair of fork with
the total number of lectures and now it should be free from deadlock and starvation 9)