CS706 Fall 2009 Homework #1 Due: Tuesday, September 15 You may work on this homework in groups of 2 - 3 students. Submit one copy of your solutions with all the group members names on it. You may *not* use any work/solutions from previous semesters. Copying assignments from previous semesters is a violation of the honor code. Submit a hard copy in class. 1. Suppose a programmer incorrectly expects statements at the source code level to always be atomic. Can this programmer see unexpected results in the following program? Thread 1 Thread 2 -------- -------- x = x-1; x = x+1; Explain your answer by comparing the possible results that can be obtained by executing the two source code statements in the two possible orders, with the possible results that can be obtained by interleaving the load-add-store statements at the assembly level. 2. Exercise 1.8 3. Exercise 1.10 (Hint: Consider the Examples in Section 1.7.2) 4. Exercise 1.11 a. Do the problem with the given data: P=10, tp(P)=3, and ts=7. b. Do the problem with the numbers reversed: P=10, tp(P)=7, and ts=3. c. In simple terms, explain the difference in speedup for (a) and (b). 5. Exercise 2.1 part (b) only 6. Exercise 2.4 7. Exercise 2.8 8. Exercise 2.11 part (a) only. (Declare an AtomicBoolean object b and use b.getAndSet() and b.set().)