Criteria for Homework 2

Steps Used for Testing

Part a (10 points)

  1. The solution was to move the call to new StringBuffer() before starting the threads. Look at the source code and check if the problem has been solved. -2
  2. Check part ii by looking at the source code. The solution was to put Thread.yield() near or inside the while loop. -2
  3. Check part iii by looking at the source code.-2
  4. Check part iv by looking at the source code. See if they have removed the call to new from the synchronized block (the String "+" operator essentially calls new since it creates temp Strings) -2. See if they are doing the concatenation of the strings outside the synchronized block -2. Should use a regular array to hold string, not Vector or ArrayList. An array is guaranteed to be efficient, it's uncertain if ArrayList has to call new -1. Should use StringBuffer instead of String -1. It is not thread safe to concat multiple times to the answer StringBuffer - correct solution used another temporary StringBuffer. While it's true that the StringBuffer is thread safe, this does not mean that multiple calls to append necessarily happen without getting interrupted between calls -3.
Perfect: 10
Each Problem: -2

Part b Thread Bank (45 points)

1) Output (run on sagas). (10) We test for two cases (a) 6k with output changed so that every account get either 999 or 1001. (b) One run on the 100k file. If you didn't print out any output at all, you got nothing.

(a) is worth 5 points if perfect, 0 otherwise
(b) is worth 5 points if perfect, 0 otherwise

If the implementation is serialized so that it's not really running in parallel, then the correct output is only worth 2 in each case instead of 5. We'll ignore little changes in the output, such as reversing the order of the two fields or incuding too much debugging output.

(The order here is written top-down which is what I suspect is the easiest order to look at their code)

2) Thread Launcher / Processor (35)

-Should create, add, run, and remove transaction in a correct and thread safe way (20)

-Should correctly make the change on both accounts. -Should handle the creation of new accounts in accordance with the constraints in the handout...these problems would manifest in slightly deviating results, that weren't always reproducible (10) Serialization special case: suppose the code is written so that it actually runs serially. (a) Take off 10 points in the section which introduces the incorrect serialization. (b) grade the other sections for their correctness assuming the code really was being used in parallel. If they are correct, then they still get the points. (c) Running serialized means they don't get most of the ouput points.

Part c: Thread Web (45 points)

Testing Drill

First we run it in a couple obvious ways to see that it parallelizes and interrupts properly. (25)

Source Code (20)

Things to check in the source (this listing is bottom-up, it may be easier to tour the source in the opposite order). It is possible to lose points both in output and source code for the same problem. However, within the source code, you can only lose points for an area once. So for example, if isInterrupted() checking is wrong or deficient, the program loses the points for that once, even though it is spread across several methods. -2 is generally for something minor. -5 corresponds to a single but significant thing not being right.