Fall02 midterm 2-solutions

Operating System Concepts, Seventh Edition

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS162 Fall 2002 Midterm 2: ******************************************************************** Problem 1 (Abraham Shaw) --exactly the same as Midterm One! ******************************************************************** NOTE: I tried to be more generous than last time, if that's possible! What are the tradeoffs between semaphores and monitors as process synchronization mechanisms? (15 points) Solution (+3 points for each of the ideas below): --Semaphores are lower level constructs than monitors or Monitors are higher level constructs than semaphores --Semaphores appear scattered throughout the program versus monitors which has synchronization code compactly located. --Monitors are safer and easier to use. --Monitors are easier to debug. --Semaphores can be implemented from simpler synchronization mechanisms provided by the hardware whereas monitors are language constructs that require compiler support --Very similar because they can each be used to implement the other Solution (+1 point for each of the ideas below): --Mutual Exclusion --Monitors can encompass many procedures --Semaphores are independent of machine platform --Sleep/Block issues Grading Comments: The question asked for tradeoffs, many students just listed what monitors were and what semaphores were. I was looking for TRADEOFFS. Even though I tried to maximize points, I could only do so much, since many students told me about condition variables and how both are used for mutual exclusion, etc when the question asks for tradeoffs as synchronization constructs. Very few students got more than half the points, so this question was definitely hard. From the solution above, I've come up with a possible 22 points. I didn't expect students to list everything; only a handful of the points above would suffice a good grade on the problem. Nevertheless, remember when you see a 15-point question, two or three sentences generally will not get you much credit. ******************************************************************** Problem 2 (David Marin) ********************************************************************
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
a) 10% of the time, there is a TLB miss (mem. ref. takes 110 ns). So 90% of the time, there isn't (mem. ref. takes 10 ns). 10% * 110 ns + 90% * 10 ns = 11 ns + 9 ns = 20 ns b) On the average, P will go 100,000 mem. refs before a page fault 100,000 memrefs * 20 ns/memref (from part a) = 2 ms (Some people interpreted "before" as not including the page fault, so they used 99,999 mem refs. instead of 100,000. I apologize, to be clear, what I should have said was "between". To deal with this, I gave full credit for answers within 1% of mine.) c) Since we're dealing with averages here, we can base our answer on an "average" set of 100,000 memory references, including one page fault From (b) we know that 100,000 memory references take 2 ms, not counting page faults. The page fault takes 20 ms to service. 2 ms + 20 ms = 22 ms. Averaged over 100,000 memory refences, we get:
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

Fall02 midterm 2-solutions - CS162 Fall 2002 Midterm 2: *...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online