CS706 Fall 2009 Homework #3 Due: Tuesday, October 20. (I may assign Hm4 before Hm3 is due, so don't delay starting this assignment.) You may work on this homework in groups. 1. Complete the UnisexBathroomSC.java Program, which has been posted for you. You should implement the *fair* strategy only (part (c)); you do not need to implement the other strategies. I created a template for you in file UnisexBathroomSC.java. Complete this code by completing SC monitor class BathroomController. You need to declare any variables you need and complete methods manEnter, manExit, womanEnter, and womanExit. Java class monitorSC is given in the Modern Multithreading library that you used in Hm2. Create and maintain counters "numMen" and "numWomen" in your program. At the point where men access the bathroom, add the check: if (numWomen>0) System.out.println("Error: concurrent access"); This detects when both men and women are in the bathroom. Do the same check with numMen when women access the bathroom. Perhaps this will help you detect errors. After your program appears to be running correctly, use the RTDriver to run your program in reachability testing mode with deadlock detection on and with the symmetry reduction on: Windows: java -classpath .;ModernMultithreading.jar -Dmode=rt -DdeadlockDetection=on -DsymmetryReduction=on RTDriver UnisexBathroomSC Unix: java -classpath .:./ModernMultithreading.jar -Dmode=rt -DdeadlockDetection=on -DsymmetryReduction=on RTDriver UnisexBathroomSC (Here I am assuming the jar file is in the same directory as your UnisexBathroomSC.java file.) Make sure you create the symmetry.txt file as explained in UserManual.pdf. (Make sure you are using the correct ThreadIDs.) You may want to comment out any calls to Thread.sleep() and any output statements before you run in rt mode. As another test, hand check your program against the following sequence: Man1 enterMen() // Man1 requests to enter the bathroom and enters Man2 enterMen() // Man2 requests to enter the bathroom and enters Woman1 enterWomen() // Woman1 requests to enter the bathroom but is delayed Man3 enterMen() // Man3 requests to enter but is delayed since Women1 waiting Man1 exitMen() Woman2 enterWomen() // Woman2 requests to enter but is delayed Man2 exitMen() /* Woman1 allowed to enter */ /* Woman2 allowed to enter */ Woman3 enterWomen() // Woman3 requests to enter but is delayed since men are waiting Woman1 exitWomen() Woman2 exitWomen() /* Man3 allowed to enter */ Man3 exitMen() /* Woman3 allowed to enter */ Woman3 exitWomen() The calls to "exerciseEvent()" in the template I gave you should help you match your code to this sequence. (By "hand check", I mean that you do not have to execute this test sequence, just inspect your code and check whether it allows the events in this test sequence to occur.) Submit: a. a listing of the bathroomController class. Do *not* submit the rest of the program. b. a statement of correctness, in which you either state that your program is (believed to be) correct or you decribe any problems that you are aware of. c. the results of reachability testing (i.e., the number of sequences that were exercised and whether any deadlocks were detected). d. an indication of whether your program appears to be able to exercise the above sequence. 2. Exercise 4-4. You should base your answer on the SC toolbox in Listing 4-23. 3. Exercise 4-13.