Computer Science 330
Operating Systems
Fall 2020, Siena College
Agenda
The Dining Friars. Siena's friars eat communal dinners from a large pot that can hold M servings of delicious Lonnstrom Dining Hall soup. When a friar wants to eat, he helps himself from the pot, unless it is empty. If the pot is empty, the friar wakes up the cook and then waits until the cook has refilled the pot, then helps himself to a serving. The behavior of the friars (they're a hungry bunch, apparently) and cook (whose life consists of sleeping and preparing soup for the friars) is defined by the following processes:
Friari: while (1) { get serving from pot; eat; }
Cook: while (1) { sleep; put M servings in pot; }
Develop psuedocode (along the lines of the Sleeping Barber solution from the notes) for the actions of the friars and the cook. Use semaphores for synchronization. The only operations permitted on the semaphores are initialization, wait, and signal. You may assume the semaphores are fair. Your solution should avoid deadlock and awaken the cook only when the pot is empty. You do not need to implement C code, just a list of shared variables and pseudocode describing the actions of the friars and the cook.