COSC 4330 3/3/97 NAME: _________________ UNIVERSITY OF HOUSTON Department of Computer Science COSC 4330-Fundamentals of Operating Systems MIDTERM EXAMINATION March 3, 1997 This exam is closed book. You can have one sheet of notes. 1. For each of the statements below, indicate whether the statement is true or false (2 points each) and explain why in one sentence (3 points each): a) Server processes normally run in privileged mode. b) Single-user systems do not need memory protection. c) Adding user-level threads to an operating system does not require any modifications to the kernel. d) A time-sharing system is a special case of a real-time system. 2. You are hired as a consultant to work on a new microkernel- based operating system. Your new employers tell you that the system is too slow and ask you to make it faster. They add they have already tried everything possible to reduce the context switch time and speed up interprocess communication. a) What else could you suggest? (5 points) b) Somebody at a meeting calls your suggestion a "Crazy idea." What can you say to show that your idea is not as crazy as it appears? (5 points) 3. Under which two possible conditions can a process return from the running state to the ready state? (2×5 points) Which of these two conditions should increase or decrease the priority of the process and why? (5 points) 4. Consider the following program: main(){ int pid, count; count = 0; if ((pid = fork()) == 0) { count++; printf("Count is equal to %d\n", count); exit(0); } while (wait(0) != pid); printf("Count is now equal to %d\n", count); } /* main */ What will be the two lines printed by the program: a) if the fork() and wait() statements refer to regular UNIX processes? (5 points) b) if they refer to lightweight processes? (5 points) 5. How will the following piece of code affect stdin, stdout and stderr? (5 points each) int fd, pd[2]; pipe(pd); fd = open("data.txt", O_RDWR | O_CREAT, 0640); close (0); dup(fd); close(2); dup(pd[1]); stdin is stdout is stderr is 6. Why would it be impossible to write a server using blocking reads and direct communication? ( 5 points) What is the best alternative? (5 points) 7. What are the two advantages of multilevel scheduling policies over the round-robin policy? (2×5 points) What’s their only major disadvantage? (5 points) 8. What are the two advantages of multilevel scheduling policies over the round-robin policy? (2×5 points) What’s their only major disadvantage? (5 points) --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. ----------------------------------------------------------------