Answered You can hire a professional tutor to get the answer.

QUESTION

the Dining Philosophers problem using the Resource Hierarchy solution to avoid deadlock in c program. The ResourceHierarchy solution will be...

the Dining Philosophers problem using the Resource Hierarchy solution to avoid deadlock in c program.

The ResourceHierarchy solution will be presented shortly. Five philosophers are numbered

from 0 through 4. Each philosopher is at the state of thinking at the beginning.

Resource hierarchy solution:

This solution to the problem is the one originally proposed by Dijkstra. It assigns

a partial order to the resources (the forks, in this case), and establishes the

convention that all resources will be requested in order, and that no two resources

unrelated by order will ever be used by a single unit of work at the same time.

Here, the resources (forks) will be numbered 1 through 5 and each unit of work

(philosopher) will always pick up the lower-numbered fork first, and then the

higher-numbered fork, from among the two forks they plan to use. The order in

which each philosopher puts down the forks does not matter. In this case, if four

of the five philosophers simultaneously pick up their lower-numbered fork, only

the highest-numbered fork will remain on the table, so the fifth philosopher will

not be able to pick up any fork. Moreover, only one philosopher will have access

to that highest-numbered fork, so they will be able to eat using two forks.

By being interactive, your program supports user inputs, which will determine

which philosopher wants to eat or think.

The commands for user interface should be interpreted as follows:

T 0

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question