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.

  1. Sit down at table.
  2. Pick up left chopstick.
  3. Pick up right chopstick.
  4. Begin eating.
  5. Continue eating for 2-7 cycles.
  6. Put down left chopstick.
  7. Put down right chopstick.
  8. Begin thinking.
  9. Continue thinking for 3-6 cycles.
  10. IF all meals have not been eaten, GOTO 2.
  11. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!