CS350 – Operating Systems Homework 2 – OzU Restaurant

$30.00

Category: Tags: , , , , , You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (4 votes)

Cooking & Dining Students Problem OzU-Rest restaurant has recently opened on campus. Its owner is a French Chef who has 3 apprentices from the Gastronomy department. Apprentices are responsible for taking the raw ingredients from the fridge and preparing them for the chef. Once they prepare enough ingredients, chef can cook the meal and customers can enjoy it. However, there are some problems in the kitchen. You, an advisor in OzuThreads company, are hired to solve these problems using your extensive CS knowledge. You are given the information below about the kitchen and the problems: – To preserve the hygiene in the kitchen, restaurant management bought 2 special pairs of gloves. However, one of them was lost, so there are only 3 gloves left. If an apprentice wants to take an ingredient from the fridge, he must wear a pair of gloves first. Gloves are on a round table that apprentices sit at when they are not working. – Each ingredient takes different times to prepare. Once an apprentice prepares the ingredient, he needs to put it into pot before he can prepare another ingredient. – Chef cooks the pot occasionally without checking the ingredients inside. Each meal takes different times for chef to cook and once he is done, he rests for 3 seconds. Each food needs to be prepared with exactly 3 ingredients given in the menu before customers enjoy it. Take the ingredient Prepare ingredient Cook it 2 PROBLEMS – Apprentices are failing to share the gloves. Each apprentice takes one of the gloves, looks at table and if he cannot find the other glove on the table, he keeps the glove until another apprentice puts his back to table. However, apprentices are quite stubborn and none of them puts his glove back to table. (Deadlock Alert!) – Apprentices and the Chef do not check the pot when they are using it. Apprentices just put whatever they prepared and chef cooks whatever is in it. There needs to be a control mechanism that prevents putting more than 3 ingredients at the pot and cooking the pot without 3 ingredients inside it. (3 Producers – 1 Consumer) SUBMISSION meal.h and kitchen.c files are given to you. You need to complete the kitchen.c file such that the problems mentioned above do not occur in your code. Parts you need to complete are mentioned in the c file with the comments. Note that you can modify the given code if you need but try to minimize the modifications in the given parts. You need to: A. Implement solutions to problems in the given kitchen.c file. (18 Pts) a. Initialize mutexes for gloves in the main function (2 pts) b. Initialize the apprentice and chef threads in the main function (3 pts) c. Complete put_gloves and remove_gloves functions to prevent deadlock problem (5 pts) d. Complete pick_ingredient, put_ingredient and chef functions to prevent producerconsumer problem (8 pts) B. Write a Makefile that you can use to: (2 Pts) – Easily compile kitchen program (using “make” command) – Define dependencies such that if any of the “.c or .h” files change it should only recompile the modified files. – Clean all object files and kitchen program with “make clean” command. SUBMISSION GUIDE: You will upload a single _hw2.tar.zip file 1- Write your name in all of your source files, e.g. /* Ismail Ari, S0001 */ 2- Make sure all codes compile and work properly. I will type only 2 commands: “make”, “kitchen” 3- Put all files (*.c, *.h, Makefile,) in a _hw2 directory and use tar to package the files as _hw2.tar (tar –cvf _hw2.tar _hw2/). gzip hw2.tar file to obtain _hw2.tar.zip and upload this file. Replace parts with your student id.