Operating System Concepts, Seventh Edition

Info icon This 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) ********************************************************************
Image of page 1

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

View Full Document Right 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: 22 ms/100,000 memrefs = 220 ns/memref d) Again, since we're dealing with averages here, we can look at an "average" set of 100,000 memory references. What does a copy of P do in 100,000 memory references? It ties up the CPU for 2 ms doing memory references (from part b) It ties up the disk for 20 ms, to service the page fault It causes the OS to tie up the CPU for 1 ms, to handle the page fault Total CPU usage: 2 ms + 1 ms = 3 ms Total disk usage: 20 ms
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern