Q: |
In HW2A, part iii and iv, are we only supposed to make changes to MagicThread.run()? |
A: |
Yes. |
Q: |
In HW2A, part iv, I don't see many ways to speed things up. There's not a lot going on there! |
A: |
Actually, there's more there than it seems. A lot is hidden by the magic Java String "+" operator. Since Strings are immutable, the "+" actually masks a call to "new String" which is how Strings get concat'ed together. Also, perhaps it's a misnomer to call this section "Performance." In fact, your overall solution might do more work in total, but keep in mind the overriding principle of minimize the amount of work that is done while holding a lock. You can actually get it down so that there's very, very little work done while holding the lock (actually at the expense of adding more work overall). This might seem ridiculous, but just imagine that the work done is more intensive than what we have here in this toy problem - then getting the most out of your concurrency is essential. |
Q: |
When is this assignment due? |
A: |
Friday, 11:59pm. So not the Thursday/Friday midnight time, rather the Friday/Saturday midnight time. In general, whenever we say the due date is midnight on a certain day, that means 11:59pm the end of that day, not 12:00am the start of that day. |
Q: |
The HW2b handout says that the Processor class should be an internal class to ThreadBank so that it can see the accounts array. Does processor really need to access this array? It seems that it can do it's job by just calling doTransaction(). |
A: |
You're right, this is a flaw in the evolution of the source code -- with the inner class Processor, it should not need the bank to be passed in the ctor. It could just use its intrinsic reference to its enclosing bank. And the Processor need not access the array either, though it's nice for debugging. |
Q: |
In HW2A, part ii, what do you mean by "mutex violation." |
A: |
A mutex violation would be a case where there's a section of code that should only be executed by one thread at a time (critical section), but it is possible for more than one thread to execute, thus violating the contraint and making bad things happen. |
Q: |
Do we count the launcher thread in our total thread count for HW2C? |
A: |
No, just the worker threads. |