UNIVERSITY OF HOUSTON Department of Computer Science COSC 4330--Fundamentals of Operating Systems FINAL EXAMINATION May 16, 1994 This exam is closed book. You can have one sheet of notes. 1. A computer has 32 bit addresses and a page size of 4 Kbytes.(2x5 points) (a) How many bits are used to represent the page number ? 12 bits because 2**12 = 4096 (b) If each page table entry occupies four bytes, what is the maximum size of a process page table? A process address space has 2**32 bytes that is 2**32/2**12=2**20 pages. Since each page table entry occupies 4 bytes, the maximum size of a page table is 2**20*4=2*22= 4 Megabytes. 2. Which of the following statements apply to these five page replacement policies: FIFO LRU Clock VMS Denning's Working Set rarely expels the right page: FIFO is a good approximation of LRU: Clock (and maybe VMS) cannot be implemented efficiently: LRU & Denning's WS is neither truly local nor truly global: VMS (20 points) 3. Why is it difficult to prevent the circular wait condition in message passing systems? (10 points) Preventing the condition would require all messages to move in one single direction. 4. A binary semaphore is a semaphore than can only have two values, namely zero and one. Write the two P(...) and V(..) procedures necessary to implement a regular semaphore using only binary semaphores assuming that the initial value of the regular semaphore is always zero. (20 points) Your global declarations (with their initial values): Your two procedures: 5. UNIX semaphores are identified by a 32 bit key that uniquely identifies the semaphore. What is the major disadvantage of this solution? (5 points) Do you have a better solution? (5 points) There is one single key space shared by all users, which makes it difficult to know if a given key value is not already used by some application. A better solution would be to associate file names with semaphores: two different users could use the same semaphore names in different directories. 6. What are the factors to consider when selecting the page size of a virtual memory system? (10 points) (1) Large page sizes reduce the overall number of page faults and the number of page table entries in each page table; (2) Small page sizes minimize internal fragmentation and require less main memory space. (3) There no point however in increasing page sizes over 4 or 8 kilobytes since it would then be likely that most of the information brought into main memory would be useless. 7. What are memory mapped files? (5 points) What is their major advantage? (5 points) Memory mapped files are files that are mapped into the virtual memory space of the processes accessing them. Once a file is mapped, it becomes part of the address space of the process. The major advantage of memory mapped files is than their contents can be accessed through standard programming constructs: Hence standard assignments can replace replace reads and writes, which reduces the number system calls and context switches. 8. What are the advantages and disadvantages of contiguous allocation of file blocks in term of (a) access times and (b) efficient utilization of the disk space? (2x5 points) (a) Contiguous allocation provides the fastest access of all disk allocation policies; (b) it will cause EXTERNAL FRAGMENTATION and does not use disk space efficiently. --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. ----------------------------------------------------------------