Name: ________________________ ALL 6 ID digits: ____________________
In Lab 3, sets change color somewhat randomly as they are formed from computing set-unions. In this midterm, you are given ColorSet, an implementation of the Set interface:
- This exam is open notes, and you can look at any code you have developed on your own or with others in studio or lab.
- The code you write for this midterm must be entirely your own, and not taken from any other source, human or electronic.
- You are not to discuss this exam with anyone except the professor.
- You are on your honor to do your work on your own.
- The exam is due at the beginning of of class on March 29. There are no extensions.
- You must use your personal repository for this exam. Try this early to make sure it works for you. No extensions will be given because of problems you have with your repository. The exam requires you to commit code and make note of commit numbers on this exam and on some printouts.
- Submission of this midterm requires you to include some printouts. You are responsible for having these ready, on-time, completing them as described below, and turning them in with your exam.
Do not email your work to me, or put your work in my mailbox. You work is due as stated above, so plan ahead to have everything ready.
- Do not worry about colorMerge yet. The multithreaded test in ColorSetTest does not use that method.
- Credit will not be given without an explanation provided in comments above each method.
- Explanations are required for why a method does or does not need to be synchronized.
- Verify your solution using the unit test, but your code must be correct even if the unit test misses something.
- Commit your code at this point, and make note of the revision number associated with ColorSet. This is necessary to receive credit.
- Print out this version of ColorSet for turning in, and write clearly on the printout:
- your name
- your ID (all 6 digits)
- the revision number for your ColorSet
- Write that revision number here as well: ___________
- Make sure all your synchronized keywords are gone from the previous part.
- Continue to ignore colorMerge. We're not ready for it yet.
- The implementation you are given for RWLock is re-entrant. A thread already holding the write lock can subsequently ask for writer or readers locks without having to wait.
- As usual, each lock acquire (re-entrant or not) must be matched by a release.
- Specify your lock actions using rwlock.acquireReadOnly(), rwlock.acquireReadWrite(), and rwlock.release(). Do not use lockInvoke.
- Use the before/after pattern to make sure locks will be released whether the code executed while holding the lock terminates normally or by exception.
- Be sure to use the appropriate lock (readers or writer) as needed.
- Explanations are required for why a section of code needs a particular kind of lock.
- Verify your solution using the unit test, but your code must be correct even if the unit test misses something.
- Commit your code at this point and make note of the revision number associated with ColorSet.
- Print out this version of ColorSet for turning in, writing clearly on the printout:
- your name
- your ID (all 6 digits)
- the revision number for your ColorSet
- Write that revision number here as well: ________________
Below, explain exactly why the deadlock occurs.
- Your code should now have hashCode() implemented as well as your solution for colorMerge.
- Commit your code at this point and make note of the revision number associated with ColorSet.
- Print out this version of ColorSet for turning in, writing clearly on the printout:
- your name
- your ID (all 6 digits)
- the revision number for your ColorSet
- Write that revision number here as well:________________