CSE 132 (Spring 2009)
Lab 3a: Maze setup
(Double Locks and Array Review)
No upload necessary, but demo to TA before leaving


This is the setup of a lab that will take 2 or 3 weeks in its entirety. Some work will be due each week. For this week, you will apply the double lock solution you developed in Studio 4 to eliminate the deadlock present in the code you are given.

You will also generalize the maze construction beyond the 2×2 maze you are given. This will involve some review of arrays. See the appropriate CSE131 material for support (or ask TA or prof). for using the KWIC index and add some interesting features.

Basic part

  1. You are really encouraged, but not required, to work in groups on this lab.
    It's really helpful to have eclipse open on one computer and this lab writeup visible on another.
  2. Open eclipse and go to your CSE132 project.
  3. Save the lab 3a zip to your desktop.
  4. In eclipse, right click CSE132 and import the zip file as a general archive file.
  5. Run the Lab class as a Java Application. Here's what you should be seeing:
  6. As with the Dining Philsophers of Studio 4, let this program run until you see deadlock.
    Explain to a TA or the prof what you see and what it means before you continue.

Next steps

  1. (5 minutes) OK so you've seen this before. Take a look at the DoubleLock implementation that came with this zip, and observe that it operates unsafely.
    Replace my implementation with one that works, and run the application again. Make sure you never see deadlock any more. Remember you can increase the pace of the Lab by modifying Lab.sleep().
  2. (15 minutes) When the Set associated with a Room changes, the color chosen in SetViz is random. Let's make it dependent on a Room's Set, so that two Rooms are in the same Set, then their visualization will appear the same color:
    Open SetViz in eclipse and look at the method computeColor. Fix that method so that it computes a Color based on the hashCode() of the Room's Set.

    Follow the advice given in comments for computeColor so that you pick colors that will work with the rest of this lab.

  3. (40 minutes) The Maze as given to you creates only a 2×2 maze. Let's generalize this to any number of rows and columns:

Demo your work

To receive credit for lab 3a, simply grab a demo sheet and demo your efforts to a TA. He or she will look over your code and you will get full credit for this lab if all is well.

What's next?

If you have time, take a look at Lab 3b. This will be discussed in class next week.

Last modified 20:10:47 CST 11 January 2010 by Ron K. Cytron