Spring 2000, CSE 428: Assignment 6


Distributed: Mar 16.
Due: Mar 28 in class. No late turnin allowed this time
Total maximum score: 100 points.
The purpose of this assignment is to provide experience with Concurrency in Java.


The object of the assignment is to define the class Semaphore in the example of Lecture 18.

Testing the solution

In order to test the solution, I would recommend the following:
  1. Create a directory called, say, "HW6", in your ~/www directory
  2. In ~/www/HW6/, create a directory called "concurrency"
  3. In ~/www/HW6/concurrency/, create two directories called "display" and "semaphore" respectively
  4. Download the source of http://www.cse.psu.edu/~catuscia/teaching/cg428/Concurrency_applets/SemaDemo.html in your ~/www/HW6/ directory (name it with the same name SemaDemo.html)
  5. Dowload all the files of http://www.cse.psu.edu/~catuscia/teaching/cg428/Concurrency_applets/concurrency/display/ in your directory ~/www/HW6/concurrency/display/. Name them with the same names as the original ones.
  6. Dowload the files SemaDemo.java, DisplaySemaphore.java, and Semaphore.java in your directory ~/www/HW6/concurrency/semaphore/. Name them with the same names as the original ones.
  7. Fill in the code for the class Semaphore in the file ~/www/HW6/concurrency/semaphore/Semaphore.java. This is the object of the assignment.
  8. In ~/www/HW6/, give the command
    javac concurrency/semaphore/SemaDemo.java
    This will cause the compilation and linking of all the .java files in the ~/www/HW6/concurrency/semaphore/ directory.
  9. Make sure that the access rights are set properly (for instance: 755 for the directories and 644 for the files)
  10. Run Netscape and open the file ~/www/HW6/SemaDemo.html
  11. If some error occurs, then correct ~/www/HW6/concurrency/semaphore/Semaphore.java and repeat steps 8 and 9 (the only rights which may have changed are those for the .class files of ~/www/HW6/concurrency/semaphore/), then restart Netscape and open again the file ~/www/HW6/SemaDemo.html. Note: It is important to restart Netscape.

Format of the solution

Please give an hard copy of your source code for the class Semaphore to the instructor by the due date. Furthermore, you should also email your source code to cg428@cse.psu.edu by the due date, so to allow us to check that your program runs correctly. Please send the code as an attachment (not by "cut-and-paste"), and use as filename the name "Semaphore.java". Make sure you write your ID in the subject of the email.

Please make sure that your program can be compiled and executed on Unix and that it is self-contained.