this is Dining
Philosophers Problem for c++ program. please see the attachment to know what you should do.notice : I have only 11 hours from knowthanks
MCS 5703 Programming Problem # 01
Dining Philosophers Problem
Imagine n philosophers who spend their lives just thinking and feasting. They sit around a circular table each in front of his own plate. However there are only n chopsticks available. Each philosopher thinks for some time. When he gets hungry he tries to pick up the two chopsticks that are closest to him. If both chopsticks are available he takes them and eats for a while. After a philosopher finishes eating he puts down the chopsticks and again starts to think.
To not disrupt each others thoughts philosophers do not communicate with each other and try to chew silently.
Write a program to simulate the behavior of the philosophers where each philosopher is a thread and the chopsticks are shared objects. Notice:
You must prevent a situation where two philosophers hold the same chop-stick at the same time.
It must never be the case that a philosopher hold one chopstick and is stuck waiting for another to get the second chopstick i.e. your program should be deadlock free.
Extend your program in such a way that philosophers never starve.
Details for submission:
Submit an executable .jar file named philosopher.jar which includes the source files.
The program should take as parameter the number of philosophers. Calling java -jar philosopher.jar 7 shall simulate seven philosophers sitting around the table.
Also in a text file provide a user documentation to outline how your program can be compiled and executed.
1
Attachments: