=========================preview======================
(COMP252)midterm98F_sol.pdf
Back to COMP252 Login to download
======================================================
COMP 252 Principles of Systems Software
Lecture Section 1
Fall Semester 1998
Midterm Examination
Date: October 27, 1998 Time: 09:00 - 10:15
Name: Solution Student ID: Email:
Instructions:
1.
This examination paper consists of 7 pages and 6 questions.
2.
Please write your name, student ID and Email on this page.
3.
For each subsequent page, please write your student ID at the top of the page in the space provided.
4.
Please answer all the questions within the space provided on the examination paper. You may use the back of the pages for your rough work.
5.
Please read each question very carefully and answer the question clearly and to the point. Make sure that your answers are neatly written, readable and legible.
6.
Show all the steps you use in deriving your answer, wherever appropriate.
7.
For each of the questions assume that the concepts are known to the graders. Concentrate on answering to the point what is asked. Do not de.ne or describe the concepts.
Question Points Score
1 10
2 10
3 10
4 20
5 25
6 25
TOTAL 100
1. We know that I/O devices are very slow compared to the speed of the CPU. List two tech-
niques that an operating system uses to keep the CPU busy while I/O operations are in progress. For each technique that you list, give a brief one or two sentence description of the technique. (10 points)
Two techniques that can be used are:
a) Spooling: In this case the I/O operations of one process are overlapped with the execu-tion of another process. The CPU uses the disk as a buffer in performing I/O
b) Multiprogramming: In this case, multiple programs are simultaneously resident in main memory. When one process issues an I/O request and gets blocked, the CPU is switched to another active process resident in memory. Time-sharing is an extension of multiprogramming where the CPU is frequently switched between processes
2. Recall the second solution to the too much milk problem. The corresponding solution for a system with two threads A and B is given below. Give a sequence of steps to show why this solution is incorrect (An example of a step is: Thread A leaves note A). (10 points)
Thread A: Thread B:
leave Note A; leave Note B;
while (Note B) while (Note A)
no-op; no-op;
if (no Milk) if (no Milk)
buy Milk; buy Milk;
remove Note A; remove Note B;
Consider the following sequence of events: a) Thread A leaves Note A b) Thread A gets interrupted and the CPU is switched to Thread B c) Thread B leaves Note B d) Thread B gets interrupted and the CPU is switched to Thread A e) Thread A executes the while loop, gets trapped into busy-waiting mode f) Thread A gets interrupted and CPU is switched to Thread B g) Thread B executes the while loop, gets trapped into busy-waiting mode Neither Thread A nor Thread B can proceed forward because they are both trapped in their
while loops waiting for the other to remove the note. This solution