CSE 132 (Spring 2011)
Lab 3a: Maze setup
(Double Locks and Array Review)

Abstract:

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).


Basic part

  1. You are really encouraged, but not required, to work in groups on this lab.
    • If the exact same people are involved, you can use the group name that you used for Lab 2a. Feel free to ask for a new group name if your groups have changed or if you want a fresh start.
    • It's really helpful to have eclipse open on one computer and this lab writeup visible on another.
  2. Open eclipse and update your workspace to see the code for this lab. All of the code is in the lab3a and its subpackages. The structure is like that you saw in Studio 4.
  3. Run the Lab class as a Java Application. Here's what you should be seeing:
  4. As with the Dining Philsophers of Studio 4, let this program run until you see deadlock. If things are too slow, then decrease the DELAY in Lab.
    Explain to a TA or the prof what you see, and what it means in terms of deadlock, 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 the code in DoubleLock with the code you developed in Studio 4 that works, and run the application again. Make sure that you never see deadlock any more. Remember you can increase the pace of the Lab by modifying DELAY in Lab.
  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:

What's next?

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

Submitting your work

A TA will demo you or your group on the day the lab is due. Before asking the TA to demo you:
When you done with this lab, you must be cleared by the TA to receive credit.

If you worked in a team using a group– repository:
  • Your work must be committed in that repository for this demo.
  • Each team member must complete this form and have the TA authenticate.
    For example, if there are two of you, then the form must be submitted twice, so that each person's last name and 6 digit ID is captured with the repository name.
  • The repository name must be included on each of the submissions.

group– Enter the name of your group repository here
Last name 6-digit ID
1

TA: Password:



Last modified 05:29:00 CST 17 February 2011 by Ron K. Cytron