Question

In: Computer Science

types of philosophers.

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.

Solutions

Expert Solution

a.         

Assume that the table is in deadlock, i.e., there is a nonempty set D of philosophers such that each Pi in D holds one fork and waits for a fork held by neighbor. Without loss of generality, assume that Pj ∈ D is a lefty. Since Pj clutches his left fork and cannot have his right fork, his right neighbor Pk never completes his dinner and is also a lefty. Therefore, Pk Œ D. continuing the argument rightward around the table shows that all philosophers in D are lefties. This contradicts the existence of at least one righty. Therefore deadlock is not possible.

 

b.

Assume that lefty Pj starves, i.e., there is a stable pattern of dining in which Pj never eats. Suppose Pj holds no fork. Then Pj's left neighbor Pi must continually hold his right fork and never finishes eating. Thus Pi is a righty holding his right fork, but never getting his left fork to complete a meal, i.e., Pi also starves. Now Pi's left neighbor must be a righty who continually holds his right fork. Proceeding leftward around the table with this argument shows that all philosophers are (starving) righties. But Pj is a lefty: a contradiction. Thus Pj must hold one fork. 

 

As Pj continually holds one fork and waits for his right fork, Pj's right neighbor Pk never sets his left fork down and never completes a meal, i.e., Pk is also a lefty who starves. If Pk did not continually hold his left fork, Pj could eat; therefore Pk holds his left fork. 

 

 

Carrying the argument rightward around the table shows that all philosophers are (starving) lefties: a contradiction. Starvation is thus precluded.


As Pj continually holds one fork and waits for his right fork, Pj's right neighbor Pk never sets his left fork down and never completes a meal, i.e., Pk is also a lefty who starves. If Pk did not continually hold his left fork, Pj could eat; therefore Pk holds his left fork. 

Related Solutions

What are the different types of utilitarianism that some philosophers advocate ? Which do you find...
What are the different types of utilitarianism that some philosophers advocate ? Which do you find the more disirable?
C programming: Using the following rules of the Dining philosophers problem: • N philosophers spend their...
C programming: Using the following rules of the Dining philosophers problem: • N philosophers spend their lives thinking and eating rice. • There are only N chopstick on the table, one between every two philosophers. • In order to eat, a philosopher needs to get hold of the two chopsticks that are closest to her. • A philosopher cannot pick up a chopstick that is already taken by a neighbor. Implement the dining philosophers problem using pthreads and monitor. Your...
What is 'existentialism'? Which philosophers are existentialists that you read about?
What is 'existentialism'? Which philosophers are existentialists that you read about?
According to the table of contents of the Heilbroner book entitled "The Wordly Philosophers: The Lives,...
According to the table of contents of the Heilbroner book entitled "The Wordly Philosophers: The Lives, the Times, and Ideas of the Great Economic Thinkers", the chapter covering Adam Smith is called "The Wonderful World of Adam Smith", and the following chapter is called "The Gloomy World of Parson Malthus and David Ricardo". Those adjectives pertain to the content of the works by those economic philosophers. Explain why Heilbroner might have chosen those titles. 2. All of the economic thinkers...
According to the text, why is it important for all to become philosophers? What does this...
According to the text, why is it important for all to become philosophers? What does this even mean? In addition to this question, why should morality be made a priority in one's life? Answer this question using support directly from the textbook.
some philosophers and scientists are instrumentalists and some are realists . write answer for arguing for...
some philosophers and scientists are instrumentalists and some are realists . write answer for arguing for that view. describe different parts of theories like observation language , theoretical language and correspondence rules. if you choose for any, give reasons why it is like that. its about philosophy.
Explain the role of Omani philosophers in calling for peace - explain? With typical mention
Explain the role of Omani philosophers in calling for peace - explain? With typical mention
One of the things that makes marx uniqe among political philosophers is that. ... A. He...
One of the things that makes marx uniqe among political philosophers is that. ... A. He had a really big beard. B. He did not want merely to interpret reality he wanted to change it. C. He had a lasting impact on how countries govern themselves D. All of the above
According to the philosopher Plato and his allegory of the cave, ________. Multiple Choice philosophers who...
According to the philosopher Plato and his allegory of the cave, ________. Multiple Choice philosophers who understood the form of the good should rule as kings philosophers saw only representations of objects, the sights and sounds that were discerned by the physical senses people trapped in the cave represented the world's intellectual masses ignorant masses escaped the cave to witness the true nature of things
Explain and juxtapose the theories of economic fairness of the Utilitarian philosophers, John Rawls, and Robert...
Explain and juxtapose the theories of economic fairness of the Utilitarian philosophers, John Rawls, and Robert Nozick.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT