Question
Dining Philosophers: Prompt the user for P (number of philosophers) and M (number of meals to be eaten). Fork a thread for a single philosopher.
Dining Philosophers: Prompt the user for P (number of philosophers) and M (number of meals to be eaten). Fork a thread for a single philosopher. The number of spoons is equal to the number of philosophers. Dining Philosophers algorithm is as follows: Sit down at table. Pick up left spoon. Pick up right spoon. Begin eating. Eat for a random number of cycles. Put down left spoon. Put down right spoon. Begin thinking. Think for random number of cycles. If all means have not been eaten, go to step 2. Else leave the table.
Philosophers will enter the room at the same time and will not sit down until all are present. None will leave until all are ready to leave.
This is also in C language, and must not use semaphores.
Step 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