UNIVERSITY OF HOUSTON Department of Computer Science COSC 4330-- Fundamentals of Operating Systems FIRST MIDTERM February 28, 1994 This exam is closed book. You can have one sheet of notes. 1. Why is it necessary to have a supervisor mode and a user mode to protect user files against unauthorized access? (10 points) Explain how this mechanism can be defeated if the computer lacks memory protection. (10 points) 2. Complete the following program fragment in such a way that all stderr output will be redirected to the file logfile. (10 points) int fildes; fildes = open("logfile", O_CREAT | O_WRONLY); 3. What is the purpose of the ready list ? (10 points) Why is it often organized as a priority queue instead of a regular FIFO queue? (10points) 4. Describe the states visited by a process from the moment it issues an I/O call to the moment it regains the CPU and explain in a few words each state transition. (15 points) 5. What is the major disadvantage of busy waits ? (10 points) Describe one case where they are nevertheless the best solu- tion. (5 points) 6. Consider the following two program fragments, which access concurrently the same shared variable count and add the necessary semaphore calls to guarantee mutual exclusion within the critical sections of both programs (20 points) Global Variables: int count = 0; semaphore ____________ = _____; semaphore ____________ = _____; Program Fragments: increment (int delta){ int collect (){ int tmp; ___________________ ___________________ count = count + delta; tmp = count; ___________________ ___________________ printf("0one! ___________________ ___________________ return(tmp); ___________________ } /* increment */ } /* collect */ --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. ----------------------------------------------------------------