COSC 4330 FINAL 12/14/99 Closed Book. You can have one sheet of notes. 1. For each of the statements below, indicate in one sentence whether or not the statement is true or false, and why (5 points each): a) There are some problems that can be solved using monitors and cannot be solved using semaphores. FALSE. You could if you wanted implement semaphores on the top of monitors b) Memory protection is always done by the computer hardware. TRUE. This is the only way to do it fast enough. c) We can prevent deadlocks in message-passing systems by denying the hold-and-wait condition. FALSE. This would require each process to receive all its messages at once. d) We can prevent deadlocks in message-passing systems by denying the mutual exclusion condition. FALSE. This would require processes to "receive" messages that were not yet sent. 2. A computer has 512 Megabytes of main memory, 32 bit addresses and a page size of eight kilobytes. a) How many page frames are there in main memory? (5 points) __ 2^(29-13) = 2^16 = 64K ______ frames b) How many bits are there in the page offset? (5 points) __ 13 __ bits (because 2^13= 8K) 3. Complete the following monitor code to implement a binary semaphore. (20 points) Class binary_semaphore { private condition go; private int a; public void synchronized P(){ _ if (a == 0) _______ _____ go.wait; _____ a = _ a - 1 _; } // P public void synchronized V() { a = _ 1 _; // THAT'S WHAT MAKES IT A BINARY SEMAPHORE go.notify; } // V binary_semaphore(){ a = 0; _____________________ } //constructor } // Class semaphore 4. Given the six following page replacement policies: Global FIFO Clock Denning's Working Set Global LRU OPT VMS indicate the policy or the policies: a) that performs worse than all other five policies (5 points): Global FIFO b) that handle real-time processes best (5 points): VMS 5. Given the following result for the "ls -lg a.ps" Unix command -rw-r----- 1 paris faculty 341993 Dec 13 18:23 a.ps a) which users can modify the file Universal.ps? (5 points) paris b) which users can read it? (5 points) paris and all members of the "faculty" group 6. What are the major advantage and disadvantage of the VMS page replacement policy? (10 points) 7. A Berkeley UNIX file system has 16 kilobyte blocks. How many bytes of any given file can be accessed: a) directly from the i-node (5 points): ________ bytes b) with one level of indirection (5 points): ________ bytes c) with two levels of indirection (5 points): _______ bytes 8. What is the difference between internal fragmentation and external fragmentation? (5 points)