Fa99 midterm 1-solutions - University of California...

Info icon This preview shows pages 1–4. Sign up to view the full content.

Page 1/1 University of California, Berkeley College of Engineering Computer Science Division – EECS Fall 1999 Anthony D. Joseph Midterm Exam #1 Solutions September 29, 1999 CS162 Operating Systems Your Name: SID and 162 Login: TA: Discussion Section: General Information: This is a closed book examination. You have two hours to answer as many questions as possible. The number in parentheses at the beginning of each question indicates 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 answers directly 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 15 3 9 4 24 5 30 6 10 Total 100
Image of page 1

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

CS 162 Fall 1999 Midterm Exam #1 September 29, 1999 Solutions Page 2/2 1. Threads – Good or bad? (12 points total): a. (6 points) List two reasons why overuse of threads is bad (i.e., using too many threads for different tasks). Be explicit in your answers. i) 3 points. “Threads are cheap, but they’re not free.” Too many threads will cause a system to spend lots of time context switching and not doing useful work. Each thread requires memory for stack space and TCBs. Too many threads and these memory uses will dominate overall memory use. ii) 3 points. Having many threads makes synchronization more complicated as you have more and more simultaneous tasks. Also, debugging is more difficult due to non-deterministic and non-reproducible execution. We did not give credit for answers that were scheduling issues (e.g., too many threads could cause starvation), since these issues also affect processes. b. (6 points) List two reasons why threads are useful/important. i) 3 points for each of two reasons. Many reasons, including: More efficient operation: overlap I/O and computation Easier to share data between threads in the same address space than between processes Modularity: A complex task can be decomposed into smaller pieces Reduced latency on multiprocessors Faster to switch between threads than between processes We did not give credit for saying that threads give you concurrency, since processes also provide concurrency. ii)
Image of page 2
CS 162 Fall 1999 Midterm Exam #1 September 29, 1999 Solutions Page 3/3 2. (15 points) For each of the following thread state transitions, say whether the transition is legal and how the transition occurs or why it cannot. Assume Mesa-style monitors. a. Change from thread state BLOCKED to thread state RUNNING . 5 points, 3 for correct answer and 2 for justification. Illegal. Threads must first be inserted into the ready queue (i.e., moved to the RUNNABLE state) before they can be executed (moved to the RUNNING state). With Mesa- style monitors, threads are placed onto the ready queue, while with Hoare-style monitors, they are immediately given the CPU (moved to the RUNNING state).
Image of page 3

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

Image of page 4
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