Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. image text in transcribed

Psudo code:

Main()

{

image text in transcribed

* 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

5. Is every industry equally attractive to expand into?

Answered: 1 week ago

Question

2. How were various roles filled?

Answered: 1 week ago

Question

2. What process will you put in place to address conflicts?

Answered: 1 week ago