midterm2-answers

midterm2-answers - Midterm #2 CMSC 433: Programming...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Midterm #2 CMSC 433: Programming Language Technologies and Paradigms November 22, 2010 Name Instructions Do not start until told to do so! This exam has 9 pages (including this one); make sure you have them all You have 75 minutes to complete the exam The exam is worth 100 points. Allocate your time wisely: some hard questions are worth only a few points, and some easy questions are worth a lot of points. If you have a question, please raise your hand and wait for the instructor. You may use the back of the exam sheets if you need extra space. In order to be eligible for partial credit, show all of your work and clearly indicate your answers. Write neatly (yes, this means you, John Toman). Credit cannot be given for illegible answers. Question Points Score Short Answer 25 Deadlock 20 Basic Erlang 25 Erlang Programming 15 Nonblocking Algorithms 15 Total 100 1. (Short answer, 25 points) (a) (5 points) Name two (out of several possible) ways to reduce lock contention. Answer: The three possibilities (you just pick two of them) are (1) Reduce duration that locks are held, e.g., using smaller synchronized blocks; (2) Reduce frequency of lock requests, e.g., via lock split- ting or striping; (3) Replace exclusive locks with coordination mechanisms that permit greater concurrency, e.g., Reader/Writer locks, non-blocking data structures etc. (b) (5 points) Name one advantage and one disadvantage of Erlangs style of concurrency vs. that of Java. Answer: Because all data in Erlang is immutable, there can be no data races. There can be atomicity violations, but they are much harder to create. On the other hand, it can be more tedious to organize communications through message passing as compared to reading and writing shared data directly. (c) Suppose we implemented a parallel maze solver that did several entire depth-first searches in parallel, but where each one followed the possible directions arising at Choice points in a different order; e.g., one task might go left, right, forward, while another might go forward, left, right. Call this strategy parallel single-DFS . Next page ... 2 i. (5 points) Summing the work done by all threads, do you think parallel-single DFS will do more work or less work than parallel BFS (breadth-first seach), e.g., as implemented in our canonical solution?...
View Full Document

This note was uploaded on 01/13/2012 for the course CMSC 433 taught by Professor Staff during the Fall '08 term at Maryland.

Page1 / 10

midterm2-answers - Midterm #2 CMSC 433: Programming...

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

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