Question: Solve the Dining Philosopher Problem using message passing. The dining philosopher problem is stated as follows: Five philosophers sit around a table. Each philosopher alternates

Solve the Dining Philosopher Problem using message passing. The dining philosopher problem is stated as follows: Five philosophers sit around a table. Each philosopher alternates between thinking and eating. In front of each philosopher there is a rice bowl. When a philosopher wishes to eat, he picks up two chopsticks next to his plate. There are, however, only five chopsticks on the table. So a philosopher can eat only when neither of his neighbors is eating. Develop a deadlock-free solution for this problem. Develop a program using C or C++ on UNIX system which will create five philosopher processes using the UNIX fork system call. These process will think, become hungry, eat until full, begin thinking again, etc. Each process will request the use of its chopsticks via a UNIX pipe system call. Show the state of all philosopher for 100 state changes. Gather and print statics for 10,000 state changes. Following is an example of pseudocode and results for this project. Solve the Dining Philosopher Problem using message passing. The dining philosopher problem

Psudo code:

Main()

{

is stated as follows: Five philosophers sit around a table. Each philosopher

* RESULT* CURRENT STATE OF EACH PHILOSOPHER> Philo.1 Philo.2 Philo.3 Philo.4 Philo.5 thinking thinking thinking thinking thinking hungry thinking thinking thinking thinking eating hungry thinking thinking thinking eating hungry hungry thinking thinking eating hungry eating hungry thinking eating hungry eating hungry hungry thinking hungry eating hungry hungry thinking hungry thinking hungry eating hungry eating thinking hungry eating hungry eating thinking hungry thinking hungry thinking thinking eating thinking eating thinking hungry eating thinking eating thinking hungry eating hungry eating thinking hungry thinking hungry eating hungry eating thinking hungry STATISTICS ON EATING STATE OF EACH PHILOSOPER Philo.1 Philo.2 Philo.3 Philo.4 Philo.5 TOTAL NO 10000 10000 10002 1000 9997

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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

Students Have Also Explored These Related Databases Questions!