COSC 4330 QUIZ #2 November 17, 1998 Closed Book. You can have one sheet of notes. 1. Complete the following sentences: (4*10 points) The initial value of a mutual exclusion semaphore should always be _ONE_. A missing _V()_ semaphore operation will often cause a deadlock. Disk blocks are said to be _REUSABLE________ resources. A situation where processes can keep some resources while waiting for other resources is called a HOLD AND WAIT______________________________________ condition. 2. True or False: (4*10 points) T ____ F _X__ Using a test and set instruction to solve the critical section problem instead of Peterson’s algorithm avoids busy waits. T _X__ F ____ Monitor conditions do not need to be initialized. T ____ F _X__ Starvation is always the result of a deadlock. T ____ F _X__ Having a circular wait is a sufficient condition for deadlock. 3. What is wrong with the following monitor procedure debiting a bank account? You may assume that balance is a private variable within the monitor handling a specific account and notonhold a monitor condition within the same monitor. (20 points) public void synchronized debit(double amount){ //check if funds are already on hold notonhold.wait; // do the debit operation balance = balance - amount; } // debit THE PROCEDURE DOES A WAIT ON A MONITOR CONDITION WITHOUT CHECKING BEFOREHAND THAT THE WAIT IS NEEDED. IT COULD THUS WAIT FOREVER. --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. ----------------------------------------------------------------