UNIVERSITY OF HOUSTON Department of Computer Science COSC 4330-Fundamentals of Operating Systems FINAL EXAMINATION May 6, 1996 This exam is closed book. You can have one sheet of notes. 1. For each of the statements below, indicate in one sentence whether the statement is correct or incorrect (2 points), and why (3 points). a) There are some problems that can be solved using semaphores and cannot be solved using monitors. FALSE: SINCE YOU CAN EMULATE SEMAPHORES WITH MONITORS THEY ARE EQUALLY POWERFUL b) It is impossible to prevent deadlocks in client-server programs. TRUE: NONE OF THE FOUR DEADLOCK PREVENTION METHODS WOULD WORK c) VMS stores process page tables in main memory. FALSE: PROCESS PAGE TABLE ARE STORED IN THE SYSTEM'S VIRTUAL MEMORY d) UNIX stores the name of a file in its i-node. FALSE: FILE NAMES ARE STORED IN DIRECTORIES (BECAUSE OTHERWISE FILES COULD NOT HAVE MULTIPLE NAMES) 2. A process has to send a message through either one of two channels, one that is cheap but very busy and the other that is faster but also more expensive. Assuming that a) several processes will be competing for these channels and b) each process using a channel must have exclusive access to that channel, implement a policy where the cheap channel is selected whenever its queue length is lesser than MAXQ and the fast channel is selected otherwise : Global Declarations: integer cheap_queue_length = 0; semaphore cheap_channel = 1; semaphore fast_channel = 1; semaphore access = 1; Process Code: (5×4 points) ___________________________________ if(cheap_queue_length < MAXQ) { /* pick cheap channel */ __________________________________ cheap_queue_length++; __________________________________ P(&cheap_channel); __________________________________ cheap_queue_length--; __________________________________ cheap_send(..); V(&cheap_channel); __________________________________ } else { /* pick fast channel */ __________________________________ P(&fast_channel); __________________________________ fast_send (..); V(&fast_channel); } /* if */ 3. Fragmentation: a) What is the difference between internal and external fragmentation? (5 points) (SEE NOTES) b) Which of them should be avoided the most and why? (5 points) EXTERNAL FRAGMENTATION BECAUSE INTERNAL FRAGMENTATION ONLY WAISTES AN AVERAGE OF HALF A PAGE PER PROCESS 4. Describe in some detail the VMS page replacement policy.(10 points: minus 3 points if there is no drawing) (SEE NOTES: TEH VMS POLICY IS THAT WITH FIXED PARTITIONS AND A SINGLE GLOBAL QUEUE) 5. A virtual memory system has a virtual address space of 4 Gigabytes and a page size of 4 kilobytes. Each page table entry occupies 4 bytes. (2x5 points) a) How many bits are used for the page number? 20 bits b) What is the maximum size of a page table? 2^22 pages 6. What are memory mapped files? (5 points) What is their major advantage? (5 points) (SEE NOTES: WITH MEMORY MAPPED FILES, THE FILE CONTENTS ARE DIRECTLY ACCESSIBLE TO THE PROGRAM) 7. What is the major advantage of access control lists over tickets? (5 points) IT IS MUCH EASIER TO REVOKE ACCESS FOR SOME BUT NOT ALL USERS (BUT TICKETS ALLOW FOR MUCH FASTER ACCESS CONTROL) 8. Are the following statements true or false for the three following file allocation methods? (5 points per correct line; no partial credits) This file allocation Sequential Linked Indexed method handles well direct T T T access is used by UNIX F F T avoids external F T T fragmentation --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. ----------------------------------------------------------------