Question: Dining Philospher probelm in C, using mutex and/or semaphores. Problem A dining philosopher follows the following rule to eat a dinner. First pick up a
Dining Philospher probelm in C, using mutex and/or semaphores.

Problem A dining philosopher follows the following rule to eat a dinner. First pick up a chopstick from the left if available, otherwise wait and try again. After grabbing the left chopstick, try to pick up the right one. If the right chopstick is available pick it up, otherwise put down the left chopstick and try again from the beginning. When having both chopsticks, eat for a while You should use only five threads (one thread for every philosopher) and semaphores or mutexes (or both) for the synchronization At the output of your program show for the eating the start and end times for every philosopher, as well as the ID of the philosopher (IDs from 01 to 05, and should not change). Set a time of 2 seconds for the eating Always should be possible to have two philosophers eating at the same time, but obviously not contiguous philosophers. End your program after every philosopher has eaten at least twice
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
