COSC 4330 QUIZ #2 April 10, 1996 CLOSED BOOK. You can have one sheet of notes. 1. A pizza oven can contain twelve pizzas but the oven narrow opening allows only two cooks at a time to either put a pizza in the oven or to take one out. Given that there can be more than two cooks preparing pizzas at any given time, complete the missing lines in the following C procedure: (40 points) semaphore oven = ______; // specify the initial value semaphore access = _______; // specify the initial value make_pizza(int size, int toppings) { prepare_dough(size); add_toppings(toppings); ______________________________________ put_into_oven(); ______________________________________ wait_until_done(); ______________________________________ take_from_oven(); ____________________________________ } // make_pizza 2. What is probably wrong with the following fragment of monitor procedure and why? (20 points) balance = read_balance(account_no); if (balance < MIN_VAL) small_account.signal; interest = balance*rate; write_balance(account_no, balance + interest); 3. How can we prevent deadlock by denying the hold and wait condition? (10 points) What is the major disadvantage of this solution? (10 points) 4. What causes external fragmentation? (10 points) What can be done to correct it? (10 points) --IMPORTANT----IMPORTANT----IMPORTANT----IMPORTANT----IMPORTANT-- Please do not try to answer these questions by yourself BEFORE having a clear idea of what's on the test for which you are studying. Materials covered in each test DO VARY from semester to semester because the pace of the course can change, some materials are be added and other deleted almost every semester. ----------------------------------------------------------------