Question: Suppose that there are two types of philosophers. One type always picks up his left fork first (a lefty), and the other type always picks

Suppose that there are two types of philosophers. One type always picks up his left fork first (a €œlefty€), and the other type always picks up his right fork first (a €œrighty€). The behavior of a lefty is defined in Figure 6.12.

Suppose that there are two types of philosophers. One type

The behavior of a righty is as follows:
begin
repeat
think;
wait ( fork[ (i+1) mod 5] );
wait ( fork[i] );
eat;
signal ( fork[i] );
signal ( fork[ (i+1) mod 5] );
forever
end;
Prove the following:
a. Any seating arrangement of lefties and righties with at least one of each avoids deadlock.
b. Any seating arrangement of lefties and righties with at least one of each prevents starvation.

program diningphilosoph ers */ semaphore fork [51 int ii void philosopher (int i) while (true) f think () wait (fork [i]) wait (fork [(i+1) mod 5]) eat ) signal (fork [ (i+1) mod 5]) signal (fork[i]) void main () parbegin (philosopher (0), philosopher (1), philosopher (2) philosopher (4)) philosopher (3)

Step by Step Solution

3.40 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a Assume that the table is in deadlock ie there is a nonempty set D of philosophers such that each P... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (1 attachment)

Word file Icon

451-C-S-D-B-O-S (104).docx

120 KBs Word File

Students Have Also Explored These Related Operating System Questions!