Question: help! c (not c++) programming practice problem. For this task, you will implement another solution to the Dining Philosophers problem. This solution will use semaphores
help! c (not c++) programming practice problem.
For this task, you will implement another solution to the Dining Philosophers problem. This solution will use semaphores as oppose to busy waiting loops for synchronization control. The only busy waiting loops to be used are the ones that allow a philosopher to eat and think for random amounts of time.
Procedure
As this task uses semaphores instead of busy waiting loops, you will need to represent the chopsticks as an array of semaphores instead of an array of Booleans.
- Sit down at table.
- Pick up left chopstick.
- Pick up right chopstick.
- Begin eating.
- Continue eating for 2-7 cycles.
- Put down left chopstick.
- Put down right chopstick.
- Begin thinking.
- Continue thinking for 3-6 cycles.
- IF all meals have not been eaten, GOTO 2.
- ELSE leave the table.
Note: Using busy waiting loops for any part of this task, apart from a philosopher eating or thinking for a random amount of time, is not allowed.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
