Question: in c language Problem 2: Sara, Mohammed, and Abdullah make coffee perfectly. Sara grinds coffee and put them in capsules. Mohammed then places the coffee

 in c language Problem 2: Sara, Mohammed, and Abdullah make coffee

in c language

Problem 2: Sara, Mohammed, and Abdullah make coffee perfectly. Sara grinds coffee and put them in capsules. Mohammed then places the coffee capsule in a coffee machine. Abdullah then serves the coffee that is done by the coffee machine. There are several synchronization constraints: 1. Mohammed cannot make a coffee unless at least one coffee capsule exists, but Mohammed does not care how far Sara gets ahead of him. 2. Abdullah cannot serve a coffee unless at least one capsule exists in which Mohammed has used in a machine to make a coffee, and the coffee has not yet been served. Abdullah does not care how far Mohammed gets ahead of him. 3. Mohammed does care that Sara does not get more than MAX capsules ahead of him. Thus, if there are MAX coffee capsules, Sara has to wait. 4. There is only one coffee machine with which both Sara and Mohammed need to prepare and use the coffee capsules, respectively. Write a multithreaded program with three threads which represent Sara, Mohammed and Abdullah using semaphores as the synchronization mechanism. . Hint : No need to provide detailed implementation regarding operations bellow: prepare_capsule(); // Sara's operation make_coffee (); // Muhammad's operation serve_coffee (); // Abdullah's operation . You can implement them as printf() statements

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!