



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Main points of this exam paper are: Heavyweight Processes, Ightweight, Threaded Applications, Several Single-Threaded, Processor, Processor Operation, I/O Operations, Processor Utilization, Turnaround Time, Cpu-Bound Tasks
Typology: Exams
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Midterm Exam March 7, 2001 Anthony D. Joseph CS162 Operating Systems
General Information: This is a closed book and note examination. You have ninety minutes to answer as many questions as possible. The number in parentheses at the beginning of each question indicated the number of points given to the question; there are 100 points in all. You should read all of the questions before starting the exam, as some of the questions are substantially more time consuming.
Write all of your answersdirectly on this paper Make your answers as concise as possible. If there is something in a question that you believe is open to interpretation, then please ask us about it!
Good Luck!!
Problem Possible Score 1 12 2 24 3 23 4 18 5 23 Total 100
1.(12 points total) "Lightweight" versus Heavyweight processes - Pros and Cons: a.(4 points) List one advantage of running several single-threaded applications as "heavyweight" processes over running the aplications as multiple "lightweight" processes, all in one address space. Be explicit, but concise , in your answers. i)
b.(8 points) List two reasons why lightweight processes are better than heavyweight ones. i)
ii)
2.(24 points total) Suppose that we have a multiprogrammed computer in whihc each job has identical characteristics. In one computation period, T, for a job, half the time is spent in I/O and the other half in processor activity. Each job runs for a total of N periods. Assume that a simple round-robin scheduling
Midterm Exam March 7, 2001 Anthony D. Joseph CS162 Operating Systems 1
scheme is used and that I/O operations can overlap with processor operation. We define the following quantities:
Turnaround time = actual time to complete job
Processor utilization = percentage of time that the processor is active (not waiting).
For large N, compute approximate values for these quantities for one, two, and four simultaneous jobs, assuming that the period T is distributed in each of the following ways:
a.(15 points) I/O first half, processor second half.
i) 1 job, Turnaround time and Processor utilization:
ii) 2 jobs, Turnaround time and Processor utilization:
ii) 4 jobs, Turnaround time and Processor utilization:
b.(9 points) I/O first and fourth quarters, processor second and third quarters.
i) 1 job, Turnaround time and Processor utilization:
ii) 2 jobs, Turnaround time and Processor utilization:
ii) 4 jobs, Turnaround time and Processor utilization:
3.(23 points total) CPU scheduling.
a.(8 points) Given CPU-bound tasks and a choice between FIFO amd Round-Robin scheduling algorithms, choose the best algortihm for each of the following systems and specify why you chose the algorithm. i)Multiprogrammed batch system:
a.(6 points) Specify the correctness constraints. Be succinct and explicint in your answer
b.(12 points) Observe that there is only one condition any thread will wait for(i.e., a water molecule being formed). However, it will be necessary to signal hydrogen and oxygen threads independently, so we choose to use two condition variables, waitingH and waitingO.
Monitor Variable name Initial value Number of waiting hydrogen threads wH 0 Number of waiting oxygen threads wO 0 Number of active hydrogen threads aH 0 Number of active oxygen threads aO 0
You start with the following code:
Hydrogen(){ wH++; lock.acquire(); while(aH ==0){ if(wH>=2 && wO >=1) { wH-=2; aH+=2; wO-=1; aO=+1; waitingH.broadcast(); waitingO.signal(); } else { lock.release(); waitingH.wait(); lock.acquire(); } } lock.release(); aH--; }
Oxygen() { wO++; while(aO ==0){ if(wH >=2 && wO >= 1){ wH-=2; aH+=2; wO-=1; aO=+1; waitingH.signal(); waitingH.signal(); } else { waitingO.broadcast(); }
aO--; }
For each method, say whether the implementation either (i) works, (ii) doesn't work, or (iii) is dangerous - that is, sometimes works and sometimes doesn't. If the implementation does not work or is dangerous, explain why (there maybe several errors) and show how to fix it so it does work. Also list and fix any inefficiencies.
i. Hydrogen()
ii. Oxygen()
Consider the following snapshot of a system with five processes(p1,...p5) and four resources (r1,...r4). There are no current outstanding queued unsatisfied requests.
currently available resources
r1 r2 r3 r 2 1 0 0 current allocation|max demand|still needs Process r1 r2 r3 r4 r1 r2 r3 r4 r1 r2 r3 r p1 0 0 1 2 0 0 1 2 p2 2 0 0 0 2 7 5 0 p3 0 0 3 4 6 6 5 6 p4 2 3 5 4 4 3 5 6