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.
Psudo code:
Main()
{
* 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 9997Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started