Author: Ron K. Cytron
| Lab |
Assigned |
Design Due (In class) 10 AM |
Implement (In Lab) Wednesday |
Demo (In Lab) Wednesday |
Lab Due (In lab) Wednesday |
| | 18 | Feb |
| |
19 | Feb |
26 | Feb |
26 | Feb |
Overview:
You are surrounded by interconnnection networks: the Internet, the network
serving your dorm room, the POTS (plain old telephone service) network.
In this lab, you create a network structure that could be used to
route message between a set of nodes. The network you create is in
fact
an unrooted tree.
Another view of this assignment: In this lab you
create a maze that could be used to have a mouse find
some tasty cheese food.
OK, I confess: the true nature of this lab is to give you experience
with threads, concurrency, visualizations, and components.
You will explore the nature and causes of deadlock as well
as the deadlock avoidance.
But
the maze and network anaologies are accurate.
Goals:
By the end of this lab, you should
- Appreciate the value of visualization in understanding progrma behavior.
- Understand how to avoid deadlock in acquiring nested locks.
- Understand the usefuleness of untangled software components.
- Appreciate the issues and tradeoffs of liveness and safety.
Before starting:
- Read this entire document before you start.
- Make sure you understand deadlock and the resource-ordering
avoidance technique presented in class and discussed in our book.
- Read the documentation
- Run the sample solution that
can deadlock.
- Run the sample solution that does
not deadlock.
Note: for this week, this is as much as you have to do. Of course
you are welcome and encouraged to work ahead.
- Run the sample solution for the
next part
- Check out the
System.identityHashCode()
method. It will be useful in two contexts for this lab:
- Picking a color for a set in the visualization
- Resource ordering
- If you need help, please ask.
You need your solution from the last lab in
addition to the following.
[[[ Download PC zip ]]]
Zip includes:
- Files you are given, but are NOT allowed to modify:
-
- Files you must complete:
-
- Files you must use and perhaps modify from last lab . If you were unable to complete the last lab, then come by for help in finishing
them up for this lab.
What is due this week?
This week, the code you are given constructs a Maze using
the Room object from last lab as well
as some new objects for this lab. The Maze shows up as a rectangular grid
of rooms. When the Hall threads are started, they simply
try to connect each of their adjacent doors. In this lab, all such
attempts will succeed.
You will first use the DoubleLock class from last lab, and
in doing so, many of your executions will deadlock. You will then fix
that object as described in class, so that your executions can never
deadlock.
If you have time, you are encouraged to move to the next
lab, which is only a change to the algorithm executed by the Hall objects.
Notes:
- Each Room has-a
Set, available through an accessor
and changeable through a mutator.
- Each hallway will be started in a separate Thread. Thus, all halls
are trying to join their rooms concurrently.
- Because of the above, it is possible that the halls request their
Rooms in a manner that results in deadlock.
- You must use the
LockPub object from the last
lab so that your visualization can show what is going on in your code.
- The
DoubleLock object from last lab
must not be modified until you have experienced the deadlock. In lab demo,
you will be asked to show the TA how you modify this object to avoid
deadlock.
What to turn in:
- Complete a code cover sheet.
- Provide a printout of any files you have modified.
Last modified 09:18:35 CST 18 February 2003
by Ron K. Cytron