FAQ for HW2

Last modified: May 23, 2001 12:10:06 AM PDT

  • In HW2A, part iii and iv, are we only supposed to make changes to ...
  • In HW2A, part iv, I don't see many ways to speed things up. ...
  • When is this assignment due?
  • The HW2b handout says that the Processor class should be an ...
  • In HW2A, part ii, what do you mean by "mutex violation."
  • Do we count the launcher thread in our total thread count for ...

    Back to the CS193k Homepage




    Q:

    In HW2A, part iii and iv, are we only supposed to make changes
    to MagicThread.run()?
    

    A:

    Yes.
    
    Back to top...


    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.
    
    
    Back to top...


    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.
    
    
    Back to top...


    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.
    
    
    Back to top...


    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.
    
    
    Back to top...


    Q:

    Do we count the launcher thread in our total thread count for HW2C?
    

    A:

    No, just the worker threads.
    
    Back to top...