Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
1 CS 320, Test 2, Fall 2003 Name:____________________________ Score:______ 40 questions, 2.5 points apiece, 100 points total. All of the questions are short answer questions. Please make your answers short and clear. If you need more room than that provided you are not focusing your answer enough. If only one out of a list of things is requested, give only one in your answer. Do not try to cover your bases by including several, hoping that one is correct. Muddy answers will not get full credit even if they include some portion that is correct. Part I. Ch. 6, CPU Scheduling. 1. What is the fundamental goal of multiprogramming as given by the author? (In effect, this is just one of the several criteria for evaluating scheduling algorithms given later.) 2. The author describes process execution as cyclical in nature. What are the two elements of the cycle? 3. For the average process, does the ratio of short duration to long duration CPU bursts tend to be high or low? 4. CPU scheduling can be done when a process switches from the running state to the waiting state. Is such scheduling preemptive or nonpreemptive? 5. CPU scheduling can be done when a process switches from the waiting state to the ready state. Is such scheduling preemptive or nonpreemptive? 6. A system may support preemption of user processes. A process may have requested an operating system service with a system call. Under what circumstances may such a user initiated system call not be interrupted? 2 7. The scheduler implements algorithms for selecting a process to run. What specific term is given to these three actions, as a group, which are applied to the process: Switching context; switching to user mode; jumping to the execution point in the user code and starting to run. 8. The author gives average waiting time and CPU utilization as criteria for evaluating scheduling algorithms. He gave three more. Give any one of those three. 9. Information about a set of processes is given below. Calculate the average waiting time for these processes under FCFS scheduling. Give your answer as a simple fraction. Process P1 P2 P3 P4 burst time 5 8 3 4 10. Information about a set of processes is given below. Calculate the average waiting time for these processes under SJF scheduling. Give your answer as a simple fraction. Process P1 P2 P3 P4 burst time 5 8 3 4 11. Information about a set of processes is given below. Calculate the average waiting time for these processes under SJF scheduling. Give your answer as a simple fraction. Process P1 P2 P3 P4 arrival time 0 4 6 8 burst time 5 8 3 4 3 12. What is the theoretical claim for SJF scheduling, and what’s the corresponding practical reality? 13. Let this formula be given: Τn+1 = αtn + (1 - α)Τn. If the estimate for T3 is fully expanded and simplified, some power of the expression (1 - α) will be the coefficient of T0. What is this power? 14. Information about a set of processes is given below. Calculate the average waiting time for these processes under priority scheduling. (A low priority number represents a high priority.) Give your answer as a simple fraction. Process P1 P2 P3 P4 priority 4 1 3 2 burst time 5 8 3 4 15. Information about a set of processes is given below. Calculate the average waiting time for these processes under RR scheduling. Let the time slice or quantum be 3. Give your answer as a simple fraction. Process P1 P2 P3 P4 burst time 5 8 3 4 16. Refer to the previous problem. If context switching takes 1 time unit on that system, including the cost of switching in the initial process, give the ratio of overhead to useful work in bringing the whole sequence of processes to completion. Give your answer as a simple fraction. 4 17. Suppose all process CPU bursts were shorter than the time slice for a round robin scheduling algorithm. Effectively, what scheduling algorithm would result in this situation? 18. In a multilevel queue scheduling system, is a process permanently assigned to a single ready queue, or can it move from one to another? 19. Take the book’s example of a multilevel feedback queue for example: Queue 0, quantum = 8; queue 1, quantum = 16; queue 2, FCFS scheduling. Under what circumstances would a process be demoted from queue 1 to queue 2? 20. Take the book’s example of a multilevel feedback queue for example: Queue 0, quantum = 8; queue 1, quantum = 16; queue 2, FCFS scheduling. Under what circumstances would it be reasonable to promote a process from queue 1 to queue 0? 21. Take the book’s example of a multilevel feedback queue for example. What statement can be made about the relative priorities of all processes in the scheduling system, relative to their queue membership? 22. For homogeneous symmetric multiprocessing, from an O/S point of view, what must exist in order to support load sharing by means of cooperative scheduling? 23. In a hard real time system a job can make a request for a system service and include a maximum completion time. Under this scenario, what are the possible, immediate system responses, and what do they signify? 24. From a scheduling algorithm point of view, the central characteristic of a soft real time operating system can be described in a phrase of two words, or also less specifically, by a single word. Give such a characterization. 5 25. What does the phrase “a user process running in the kernel” mean? Part II. Ch. 7, Process Synchronization, through section 7.5. 26. Let 2 unsynchronized threads have access to a shared variable, count. Let there be a section of code, A: reg1 = count; reg1 = reg1 + 1; count = reg1. Let there be another section of code, B: reg2 = count; reg2 = reg2 – 1; count = reg2. If one thread runs A while the other thread runs B, and these code segments are nonatomic, what is the set of all possible outcomes for the variable count? 27. Give the 3 requirements for a correct solution to the critical section problem. 28. Suppose you try to manage concurrency of 2 threads in a critical section by means of a single variable that keeps track of which thread’s turn it is. Let the turn be arbitrarily set at the beginning to indicate that it’s one or the other thread’s turn, and let it be reset to the other thread’s turn when a given thread leaves the critical section. Which of the 3 requirements for a correct solution to the critical section problem is violated by this solution, and how? 29. Suppose you try to manage concurrency of 2 threads in a critical section by means of 2 flags, one for each thread. Let each thread set its flag to true when trying to enter the critical section. Let successfully entering of the critical section depend on the other thread’s flag not being true. Let each thread set its flag to false when leaving the critical section. Which of the 3 requirements for a correct solution to the critical section problem is violated by this solution, and how? 6 30. A correct solution to the critical section problem is shown below. Under this solution, if 2 threads both want to enter the critical section, state concisely, in terms of the execution sequence of one of the lines shown in the solution, which thread will yield to the other. public void enteringCriticalSection(int t) { int other = 1 - t; if (t == 0) flag0 = true; else flag1 = true; turn = other; if (t == 0) { while ( (flag1 == true) && (turn == other) ) Thread.yield(); } else { while ( (flag0 == true) && (turn == other) ) Thread.yield(); } } 31. The functionality of a hardware testandset() instruction is roughly apparent from its name. What characteristic does such an instruction have that makes it useful in implementing synchronization? 32. From a hardware point of view, assuming it’s possible in the architecture, critical sections can be protected by disabling interrupts for the duration of that section of code. From the operating system point of view, what does this disabling of interrupts accomplish? 33. Will disabling interrupts protect critical sections in all environments? If not, in what environments does it work, and in what environments does it not work? 34. Various scenarios can be described as deadlock. What are the minimum number of resources and the minimum number of processes needed to illustrate the classical definition of deadlock? 7 Let the following pseudo-code definition of semaphore operations, taken from the book, be given for the next few questions. P(S) { while(S <= 0) { ; S--; } V(S) { S++; } 35. Although not indicated syntactically, what has to be true of these implementations of P() and V() in order for this to be a correct solution to synchronization using the semaphore S? 36. In user code, show how calls to P() and V() would be used to protect a critical section. 37. Make a statement about the possibility or meaning of the following 3 situations under the definitions given above. a. S > 0 b. S == 0 c. S < 0 38. What is the disadvantage of the semaphore solution given above? Don’t overlook the questions on the back of this page. 8 Let the following pseudo-code definition of semaphore operations, taken from the book, be given for the next few questions. P(S) { value--; if(value < 0) { add process to list; block; } } V(S) { value++; if(value <= 0) { remove process P from list; wakeup(P); } } 39. Make a statement about the possibility or meaning of the following 3 situations under the definitions given above. a. S > 0 b. S == 0 c. S < 0 40. There is a relationship between the queuing discipline for the list mentioned in the definitions given above and one of the requirements for a correct solution to the critical section problem. What is it?