Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Project Description: There are four students sitting in a room: three juniors and one senior. Each of the juniors will make a sandwich and eat
Project Description: There are four students sitting in a room: three juniors and one senior. Each of the juniors will make a sandwich and eat it. To make a sandwich requires bread, cheese, and sausage. Each junior has one of the three items, that is, one has bread, another has cheese and the third has sausage. The senior has infinite supply of all three items. The senior places two of the three items on the table, and the junior that has the third item, makes the sandwich. However, the other two juniors cannot make a sandwich because they do not have the third required item. The junior who has the remaining ingredient then makes and eats the sandwich, signaling the senior on completion. The senior then puts out another two of the three ingredients and the cycle repeats. Implement a synchronization method to solve the problem. You must output the progress of the processes. E.g. when the senior places the two ingredients you should print that information. When a junior gets to make a sandwich, output which junior got the ingredients and so on. Show the run of your processes for a while until around 10 sandwiches are made
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started