Question: You are required to complete a Synchronization problem in C . The dining philosophers problem is a well known synchronization problem in CS , it
You are required to complete a Synchronization problem in C
The dining philosophers problem is a well known synchronization problem in CS it introduces N
processes trying to access shared resources. The rules of the problem state that a philosopher must think,
become hungry, and then try to acquire chopsticks. A diner
must have both chopsticks the one on their left and right to
eat. After eating, the diner puts both chopsticks down
and goes back to thinking.
Your task is to implement the dining philosopher problem
as an endless buffet', no stop condition, with a viable solution.
The program is expected to take one number from command
line arguments to indicate the number of diners and chopsticks.
Include some input handling to ensure N
Using semaphores, you are tasked within controlling access to the chopsticks:
Each chopstick can be represented as a semaphore:
Philosophers must wait to acquire both semaphores chopsticks
Philosophers eat, if they can,
Philosophers put down right chopstrick, then left chopstick.
Starter code is provided. Fill the blank spaces under comments for mark
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
