- Java 99.1%
- Nix 0.9%
| .gitignore | ||
| BugExercise1.java | ||
| BugExercise2.java | ||
| BugExercise3.java | ||
| BugExercise4.java | ||
| BugExercise5.java | ||
| BugExercise6.java | ||
| common-mistakes.md | ||
| Exam.java | ||
| flake.lock | ||
| flake.nix | ||
| README.md | ||
Exam Project on Concurrent Programming
The exam project consists of two parts, namely development and bug-hunting. The first part accounts for roughly 70% of the grade and the second for roughly 30%. Instructions on how to hand in will be published soon. This is not a group project: every student must work on their own assignment by themselves.
An assignment will be opened for handing in the project, with deadline 01 June 2026 at 16:00 (local time). Detailed instructions are given below.
You can find a list of common mistakes that people do in the exam for
this course in file common-mistakes.md. Please read it after reading the
following instructions.
Part 1: Development
For this part, you have to edit and hand in a single Java file called Exam.java.
To prepare for this part, follow these steps:
- Read the contents of
Exam.javawhich describes the task that you have to complete for this part. You will find in particular a few methods that throwUnsupportedOperationException: you have to remove the throw instruction and implement those methods by following their documentation.
As described in Exam.java, your task is to implement a few methods of class
Exam. Please note the following rules
(violating any of them might severely affect the grade):
- You cannot change the code of method
main, nor any code marked withDo not change. - You cannot change the types of what the methods that you have to implement take as parameters or return.
- You cannot create new files. Your entire implementation must be inside of
Exam.java. - For Part 1, you must hand in exactly one file, namely
Exam.java. Do not upload any other files, and do not put the file inside of any directory. Just upload that single file. If you have comments regarding your code, put them as Java comments in the methods that you implemented inside ofExam.java. - Including external libraries is forbidden: you can only use the Java standard library.
You are welcome to create additional methods to structure your project, and also
to create additional classes as long as they are in the same Exam.java file.
Do not create other files: the development part must consist only of the file
Exam.java that you write.
Allowed concurrency strategies
Some of the methods that you have to implement come with restrictions on what strategy you can follow, which is pointed out in the comment right above the method definition (right after 'Allowed concurrency strategy'). They are to be interpreted quite literally:
- All: you can use any concurrency strategy.
- Virtual threads: you must use virtual threads to solve the exercise.
Testing
Class Exam comes with a main method that implements a simple command line
interface, which allows you to test your methods.
From the directory where you have stored Exam.java, run java Exam.java help
to check whether you set up is working. (There is no need to compile it if
you are using Java 11 or above.)
The methods that you have to implement have to search for text files in a
directory. To test your project, you can use the directory data inside of this
zip file: https://raw.githubusercontent.com/fmontesi/cp-2024/main/exam/data.zip.
For example, you can unzip data.zip in the same directory where you have your
Exam.java file and launch from that directory the command
java Exam.java allLines data. The directory that I will use in the evaluation
will follow the same format, but it will be different.
Evaluation criteria
Evaluation will be based on the following criteria.
- Correctness: Are the methods implemented as requested, and do they operate correctly?
- Efficiency: Is concurrency used efficiently to achieve better performance than a sequential program?
- Scalability: Does the implementation scale well with respect to the number of available cores?
- Readability: Is the code easy to read and understand?
It is not necessary to maximize for any of these criteria (an excellent exam will typically strike a good trade-off between efficiency and readability, for example).
Part 2: Bug Hunting
The bug hunting part consists of six standalone files:
BugExercise1.java, BugExercise2.java,...,BugExercise6.java.
Each file implements a combination of classes that simulate a specific
concurrency scenario. Your objective is to identify and fix the bugs in each
file. More specifically, to complete this part, you have to do the following
for each file:
- Identify the bug(s) and write a short (e.g. 3-4 sentences) description of them.
- Fix the bugs and briefly (e.g. 3-4 sentences) explain your fixes.
The summary of the bugs and the fixes should be placed at the beginning of each file as a comment. You must demonstrate a good understanding of concurrency issues and the various strategies to avoid/fix them.
Important: All the bugs are present in the classes, not the main method.
The main method for each file is merely an interface to experiment and trigger
the bugs. What this means is that changing main so that it does not trigger
the bug does not constitute a solution.
The deliverables of this part consists only of your modified files
BugExercise1.java, BugExercise2.java,...,BugExercise6.java.
Remarks
- Your fixes in
BugExercise2.javashould not apply to classesToolandRecipe. - In
BugExercise3.java, the suppliedmainmethod does not trigger any bugs. Figuring out the nature of the issues is part of the challenge.
Frequently Asked Questions and Comments
Part 1
-
Be careful with thread termination: when I measure the time that your methods take to terminate, having threads that have not terminated may slow down the measurement.
-
What encoding will the files be in? UTF-8. I will not use any weird characters that require thinking of more than a Java
char. I do not recommend using byte representations of strings. -
This is useful if you want to test how your project scales with respect to the number of cores: How do I de-activate CPU cores in Linux? See http://www.cyberciti.biz/faq/debian-rhel-centos-redhat-suse-hotplug-cpu/.
Other remarks
You can use any IDE or editor you like during the development, as long as all
you hand in is just Exam.java and the file keeps working by itself by invoking
java Exam.java from the command line. No project files or similar can be
uploaded. The same stands for Part 2: all you have to hand in are files
BugExercise1.java, BugExercise2.java,...,BugExercise3.java.
When you start implementing a method in Exam, remove the
throw new UnsupportedOperationException(); line from it first. If you do not
manage to implement a method, then keep that line instead so that I know you
chose not to give an implementation for that particular method.